Re: [Intel-gfx] [PATCH 00/12] drm: Put drm_display_mode on diet

2020-02-21 Thread Ville Syrjälä
On Fri, Feb 21, 2020 at 06:16:57PM +0100, Daniel Vetter wrote:
> On Fri, Feb 21, 2020 at 06:09:04PM +0200, Ville Syrjälä wrote:
> > On Fri, Feb 21, 2020 at 05:40:31PM +0200, Ville Syrjälä wrote:
> > > On Fri, Feb 21, 2020 at 03:42:56PM +0100, Daniel Vetter wrote:
> > > > On Fri, Feb 21, 2020 at 12:43 PM Ville Syrjälä
> > > >  wrote:
> > > > >
> > > > > On Fri, Feb 21, 2020 at 01:32:29PM +0200, Jani Nikula wrote:
> > > > > > On Thu, 20 Feb 2020, Ville Syrjälä  
> > > > > > wrote:
> > > > > > > Looks like getting rid of private_flags is going to be pretty
> > > > > > > straightforward. I'll post patches for that once this first series
> > > > > > > lands.
> > > > > >
> > > > > > Going all in on crtc state? I suppose migrating away from 
> > > > > > private_flags
> > > > > > could easily start in i915 before that. Seems rather independent.
> > > > > >
> > > > > > I guess it's __intel_get_crtc_scanline() and:
> > > > > >
> > > > > >   vblank = >base.dev->vblank[drm_crtc_index(>base)];
> > > > > >   mode = >hwmode;
> > > > > >
> > > > > >   if (mode->private_flags & 
> > > > > > I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP)
> > > > > >
> > > > > > that gives me the creeps in reviewing all that.
> > > > > >
> > > > > > There's also [1] adding new uses for private_flags; I think there 
> > > > > > were
> > > > > > issues in getting at the right crtc state on some of those paths, 
> > > > > > but I
> > > > > > forget the exact details. Ideas?
> > > > >
> > > > > I'm just going to move them to the crtc_state and put a copy into the
> > > > > crtc itself for the vblank code. Pretty much a 1:1 replacement.
> > > > > Saves me from having to think ;)
> > > > 
> > > > I've looked through the patches, and didn't spot any place where we
> > > > couldn't just get at the full crtc state. Might need some crtc->state
> > > > dereferencing and upcasting and making sure stuff is ordered correctly
> > > > with enable/disable paths of crtc, but nothing to jump over.
> > > 
> > > swap_state() could easily race with the irq handler. I guess
> > > practically unlikely the old crtc state would disappear before
> > > the irq handler is done, but still seems somewhat dubious.
> > 
> > And I guess the bigger problem is that swap_state() happens way too
> > early. So crtc->state would be pointing to bogus stuff while we're
> > disabling the crtc.
> 
> Uh, so we're essentially piggy-packing some random i915 state on top of
> the hw timing stuff the vblank handler does, and hope that this is
> race-free enough to not matter?
> 
> I think the right solution there would be to have a proper
> spinlock_irqsafe for this stuff that the dsi TE handler needs, and through
> that make sure that we're actually not going boom. At least it looked like
> there's also irq handling bits outside of the vblank code, so the vblank
> locking is not going to safe the day.

I haven't actually looked at the DSI TE stuff so far, so no
idea what's going on there.

-- 
Ville Syrjälä
Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH 00/12] drm: Put drm_display_mode on diet

2020-02-21 Thread Daniel Vetter
On Fri, Feb 21, 2020 at 06:09:04PM +0200, Ville Syrjälä wrote:
> On Fri, Feb 21, 2020 at 05:40:31PM +0200, Ville Syrjälä wrote:
> > On Fri, Feb 21, 2020 at 03:42:56PM +0100, Daniel Vetter wrote:
> > > On Fri, Feb 21, 2020 at 12:43 PM Ville Syrjälä
> > >  wrote:
> > > >
> > > > On Fri, Feb 21, 2020 at 01:32:29PM +0200, Jani Nikula wrote:
> > > > > On Thu, 20 Feb 2020, Ville Syrjälä  
> > > > > wrote:
> > > > > > Looks like getting rid of private_flags is going to be pretty
> > > > > > straightforward. I'll post patches for that once this first series
> > > > > > lands.
> > > > >
> > > > > Going all in on crtc state? I suppose migrating away from 
> > > > > private_flags
> > > > > could easily start in i915 before that. Seems rather independent.
> > > > >
> > > > > I guess it's __intel_get_crtc_scanline() and:
> > > > >
> > > > >   vblank = >base.dev->vblank[drm_crtc_index(>base)];
> > > > >   mode = >hwmode;
> > > > >
> > > > >   if (mode->private_flags & 
> > > > > I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP)
> > > > >
> > > > > that gives me the creeps in reviewing all that.
> > > > >
> > > > > There's also [1] adding new uses for private_flags; I think there were
> > > > > issues in getting at the right crtc state on some of those paths, but 
> > > > > I
> > > > > forget the exact details. Ideas?
> > > >
> > > > I'm just going to move them to the crtc_state and put a copy into the
> > > > crtc itself for the vblank code. Pretty much a 1:1 replacement.
> > > > Saves me from having to think ;)
> > > 
> > > I've looked through the patches, and didn't spot any place where we
> > > couldn't just get at the full crtc state. Might need some crtc->state
> > > dereferencing and upcasting and making sure stuff is ordered correctly
> > > with enable/disable paths of crtc, but nothing to jump over.
> > 
> > swap_state() could easily race with the irq handler. I guess
> > practically unlikely the old crtc state would disappear before
> > the irq handler is done, but still seems somewhat dubious.
> 
> And I guess the bigger problem is that swap_state() happens way too
> early. So crtc->state would be pointing to bogus stuff while we're
> disabling the crtc.

Uh, so we're essentially piggy-packing some random i915 state on top of
the hw timing stuff the vblank handler does, and hope that this is
race-free enough to not matter?

I think the right solution there would be to have a proper
spinlock_irqsafe for this stuff that the dsi TE handler needs, and through
that make sure that we're actually not going boom. At least it looked like
there's also irq handling bits outside of the vblank code, so the vblank
locking is not going to safe the day.

Or maybe it's really just too late and I should go into w/e :-)
-Daniel
-- 
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


Re: [Intel-gfx] [PATCH 00/12] drm: Put drm_display_mode on diet

2020-02-21 Thread Ville Syrjälä
On Fri, Feb 21, 2020 at 05:40:31PM +0200, Ville Syrjälä wrote:
> On Fri, Feb 21, 2020 at 03:42:56PM +0100, Daniel Vetter wrote:
> > On Fri, Feb 21, 2020 at 12:43 PM Ville Syrjälä
> >  wrote:
> > >
> > > On Fri, Feb 21, 2020 at 01:32:29PM +0200, Jani Nikula wrote:
> > > > On Thu, 20 Feb 2020, Ville Syrjälä  
> > > > wrote:
> > > > > Looks like getting rid of private_flags is going to be pretty
> > > > > straightforward. I'll post patches for that once this first series
> > > > > lands.
> > > >
> > > > Going all in on crtc state? I suppose migrating away from private_flags
> > > > could easily start in i915 before that. Seems rather independent.
> > > >
> > > > I guess it's __intel_get_crtc_scanline() and:
> > > >
> > > >   vblank = >base.dev->vblank[drm_crtc_index(>base)];
> > > >   mode = >hwmode;
> > > >
> > > >   if (mode->private_flags & 
> > > > I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP)
> > > >
> > > > that gives me the creeps in reviewing all that.
> > > >
> > > > There's also [1] adding new uses for private_flags; I think there were
> > > > issues in getting at the right crtc state on some of those paths, but I
> > > > forget the exact details. Ideas?
> > >
> > > I'm just going to move them to the crtc_state and put a copy into the
> > > crtc itself for the vblank code. Pretty much a 1:1 replacement.
> > > Saves me from having to think ;)
> > 
> > I've looked through the patches, and didn't spot any place where we
> > couldn't just get at the full crtc state. Might need some crtc->state
> > dereferencing and upcasting and making sure stuff is ordered correctly
> > with enable/disable paths of crtc, but nothing to jump over.
> 
> swap_state() could easily race with the irq handler. I guess
> practically unlikely the old crtc state would disappear before
> the irq handler is done, but still seems somewhat dubious.

And I guess the bigger problem is that swap_state() happens way too
early. So crtc->state would be pointing to bogus stuff while we're
disabling the crtc.

-- 
Ville Syrjälä
Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH 00/12] drm: Put drm_display_mode on diet

2020-02-21 Thread Ville Syrjälä
On Fri, Feb 21, 2020 at 03:42:56PM +0100, Daniel Vetter wrote:
> On Fri, Feb 21, 2020 at 12:43 PM Ville Syrjälä
>  wrote:
> >
> > On Fri, Feb 21, 2020 at 01:32:29PM +0200, Jani Nikula wrote:
> > > On Thu, 20 Feb 2020, Ville Syrjälä  wrote:
> > > > Looks like getting rid of private_flags is going to be pretty
> > > > straightforward. I'll post patches for that once this first series
> > > > lands.
> > >
> > > Going all in on crtc state? I suppose migrating away from private_flags
> > > could easily start in i915 before that. Seems rather independent.
> > >
> > > I guess it's __intel_get_crtc_scanline() and:
> > >
> > >   vblank = >base.dev->vblank[drm_crtc_index(>base)];
> > >   mode = >hwmode;
> > >
> > >   if (mode->private_flags & 
> > > I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP)
> > >
> > > that gives me the creeps in reviewing all that.
> > >
> > > There's also [1] adding new uses for private_flags; I think there were
> > > issues in getting at the right crtc state on some of those paths, but I
> > > forget the exact details. Ideas?
> >
> > I'm just going to move them to the crtc_state and put a copy into the
> > crtc itself for the vblank code. Pretty much a 1:1 replacement.
> > Saves me from having to think ;)
> 
> I've looked through the patches, and didn't spot any place where we
> couldn't just get at the full crtc state. Might need some crtc->state
> dereferencing and upcasting and making sure stuff is ordered correctly
> with enable/disable paths of crtc, but nothing to jump over.

swap_state() could easily race with the irq handler. I guess
practically unlikely the old crtc state would disappear before
the irq handler is done, but still seems somewhat dubious.

-- 
Ville Syrjälä
Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH 00/12] drm: Put drm_display_mode on diet

2020-02-21 Thread Daniel Vetter
On Fri, Feb 21, 2020 at 12:43 PM Ville Syrjälä
 wrote:
>
> On Fri, Feb 21, 2020 at 01:32:29PM +0200, Jani Nikula wrote:
> > On Thu, 20 Feb 2020, Ville Syrjälä  wrote:
> > > Looks like getting rid of private_flags is going to be pretty
> > > straightforward. I'll post patches for that once this first series
> > > lands.
> >
> > Going all in on crtc state? I suppose migrating away from private_flags
> > could easily start in i915 before that. Seems rather independent.
> >
> > I guess it's __intel_get_crtc_scanline() and:
> >
> >   vblank = >base.dev->vblank[drm_crtc_index(>base)];
> >   mode = >hwmode;
> >
> >   if (mode->private_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP)
> >
> > that gives me the creeps in reviewing all that.
> >
> > There's also [1] adding new uses for private_flags; I think there were
> > issues in getting at the right crtc state on some of those paths, but I
> > forget the exact details. Ideas?
>
> I'm just going to move them to the crtc_state and put a copy into the
> crtc itself for the vblank code. Pretty much a 1:1 replacement.
> Saves me from having to think ;)

I've looked through the patches, and didn't spot any place where we
couldn't just get at the full crtc state. Might need some crtc->state
dereferencing and upcasting and making sure stuff is ordered correctly
with enable/disable paths of crtc, but nothing to jump over.

Was this maybe predating the switch of the vblank callbacks over from
drm_driver to drm_crtc_funcs, and in the former it's indeed not
super-obvious that you can just look at the crtc? Anyway, didn't look
like it needs private flags at all from a quick scan.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH 00/12] drm: Put drm_display_mode on diet

2020-02-21 Thread Ville Syrjälä
On Fri, Feb 21, 2020 at 01:32:29PM +0200, Jani Nikula wrote:
> On Thu, 20 Feb 2020, Ville Syrjälä  wrote:
> > Looks like getting rid of private_flags is going to be pretty
> > straightforward. I'll post patches for that once this first series
> > lands.
> 
> Going all in on crtc state? I suppose migrating away from private_flags
> could easily start in i915 before that. Seems rather independent.
> 
> I guess it's __intel_get_crtc_scanline() and:
> 
>   vblank = >base.dev->vblank[drm_crtc_index(>base)];
>   mode = >hwmode;
> 
>   if (mode->private_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP)
> 
> that gives me the creeps in reviewing all that.
> 
> There's also [1] adding new uses for private_flags; I think there were
> issues in getting at the right crtc state on some of those paths, but I
> forget the exact details. Ideas?

I'm just going to move them to the crtc_state and put a copy into the
crtc itself for the vblank code. Pretty much a 1:1 replacement. 
Saves me from having to think ;)

-- 
Ville Syrjälä
Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH 00/12] drm: Put drm_display_mode on diet

2020-02-21 Thread Jani Nikula
On Thu, 20 Feb 2020, Ville Syrjälä  wrote:
> Looks like getting rid of private_flags is going to be pretty
> straightforward. I'll post patches for that once this first series
> lands.

Going all in on crtc state? I suppose migrating away from private_flags
could easily start in i915 before that. Seems rather independent.

I guess it's __intel_get_crtc_scanline() and:

vblank = >base.dev->vblank[drm_crtc_index(>base)];
mode = >hwmode;

if (mode->private_flags & I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP)

that gives me the creeps in reviewing all that.

There's also [1] adding new uses for private_flags; I think there were
issues in getting at the right crtc state on some of those paths, but I
forget the exact details. Ideas?

BR,
Jani.


[1] https://patchwork.freedesktop.org/series/69290/



-- 
Jani Nikula, Intel Open Source Graphics Center
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [Intel-gfx] [PATCH 00/12] drm: Put drm_display_mode on diet

2020-02-20 Thread Ville Syrjälä
On Thu, Feb 20, 2020 at 04:27:59PM +0200, Ville Syrjälä wrote:
> On Thu, Feb 20, 2020 at 01:21:03PM +, Emil Velikov wrote:
> > On Wed, 19 Feb 2020 at 20:35, Ville Syrjala
> >  wrote:
> > >
> > > From: Ville Syrjälä 
> > >
> > > struct drm_display_mode is extremely fat. Put it on diet.
> > >
> > > Some stats for the whole series:
> > >
> > > 64bit sizeof(struct drm_display_mode):
> > > 200 -> 136 bytes (-32%)
> > >
> > > 64bit bloat-o-meter -c drm.ko:
> > > add/remove: 1/0 grow/shrink: 29/47 up/down: 893/-1544 (-651)
> > > Function old new   delta
> > > ...
> > > Total: Before=189430, After=188779, chg -0.34%
> > > add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0)
> > > Data old new   delta
> > > Total: Before=11667, After=11667, chg +0.00%
> > > add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-16896 (-16896)
> > > RO Data  old new   delta
> > > edid_4k_modes   1000 680-320
> > > edid_est_modes  34002312   -1088
> > > edid_cea_modes_193  54003672   -1728
> > > drm_dmt_modes  17600   11968   -5632
> > > edid_cea_modes_1   25400   17272   -8128
> > > Total: Before=71239, After=54343, chg -23.72%
> > >
> > >
> > > 64bit bloat-o-meter drm.ko:
> > > add/remove: 1/0 grow/shrink: 29/52 up/down: 893/-18440 (-17547)
> > > ...
> > > Total: Before=272336, After=254789, chg -6.44%
> > >
> > >
> > > 32bit sizeof(struct drm_display_mode):
> > > 184 -> 120 bytes (-34%)
> > >
> > > 32bit bloat-o-meter -c drm.ko
> > > add/remove: 1/0 grow/shrink: 19/21 up/down: 743/-1368 (-625)
> > > Function old new   delta
> > > ...
> > > Total: Before=172359, After=171734, chg -0.36%
> > > add/remove: 0/0 grow/shrink: 0/0 up/down: 0/0 (0)
> > > Data old new   delta
> > > Total: Before=4227, After=4227, chg +0.00%
> > > add/remove: 0/0 grow/shrink: 0/5 up/down: 0/-16896 (-16896)
> > > RO Data  old new   delta
> > > edid_4k_modes920 600-320
> > > edid_est_modes  31282040   -1088
> > > edid_cea_modes_193  49683240   -1728
> > > drm_dmt_modes  16192   10560   -5632
> > > edid_cea_modes_1   23368   15240   -8128
> > > Total: Before=59230, After=42334, chg -28.53%
> > >
> > > 32bit bloat-o-meter drm.ko:
> > > add/remove: 1/0 grow/shrink: 19/26 up/down: 743/-18264 (-17521)
> > > ...
> > > Total: Before=235816, After=218295, chg -7.43%
> > >
> > >
> > > Some ideas for further reduction:
> > > - Convert mode->name to a pointer (saves 24/28 bytes in the
> > >   struct but would often require a heap alloc for the name (though
> > >   typical mode name is <10 bytes so still overall win perhaps)
> > > - Get rid of mode->name entirely? I guess setcrtc & co. is the only
> > >   place where we have to preserve the user provided name, elsewhere
> > >   could pehaps just generate on demand? Not sure how tricky this
> > >   would get.
> > 
> > The series does some great work, with future work reaching the cache
> > line for 64bit.
> > Doing much more than that might be an overkill IMHO.
> > 
> > In particular, if we change DRM_DISPLAY_MODE_LEN to 24 we get there,
> > avoiding the heap alloc/calc on demand fun.
> > While also ensuring the name is sufficiently large for the next decade or 
> > so.
> 
> Unfortunately it's part of the uabi. So can't change it without some
> risk of userspace breakage.
> 
> The least demanding option is probably to nuke export_head. We need
> one bit to replace it, which we can get by either:
> - stealing from eg. mode->type, or perhaps mode->private_flags
> - nuke private_flags outright and replace it with a bool for this
>   purpose

Looks like getting rid of private_flags is going to be pretty
straightforward. I'll post patches for that once this first series
lands.

-- 
Ville Syrjälä
Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel