dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Sam Ravnborg <sam@ravnborg.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	intel-gfx@lists.freedesktop.org,
	Emil Velikov <emil.l.velikov@gmail.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 15/17] drm/gma500: Stop using mode->private_flags
Date: Thu, 9 Apr 2020 22:49:52 +0300	[thread overview]
Message-ID: <20200409194952.GZ6112@intel.com> (raw)
In-Reply-To: <20200407193537.GA28584@ravnborg.org>

On Tue, Apr 07, 2020 at 09:35:37PM +0200, Sam Ravnborg wrote:
> On Tue, Apr 07, 2020 at 10:08:00PM +0300, Ville Syrjälä wrote:
> > On Tue, Apr 07, 2020 at 08:56:53PM +0200, Sam Ravnborg wrote:
> > > Hi Ville.
> > > 
> > > On Fri, Apr 03, 2020 at 11:40:06PM +0300, Ville Syrjala wrote:
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > 
> > > > gma500 only uses mode->private_flags to convey the sdvo pixel
> > > > multiplier from the encoder .mode_fixup() hook to the encoder
> > > > .mode_set() hook. Those always seems get called as a pair so
> > > > let's just stuff the pixel multiplier into the encoder itself
> > > > as there are no state objects we could use in this non-atomic
> > > > driver.
> > > > 
> > > > Paves the way for nuking mode->private_flag.
> > > Nice little clean-up. One comment below.
> > > 
> > > 	Sam
> > > > 
> > > > Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
> > > > CC: Sam Ravnborg <sam@ravnborg.org>
> > > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > > Cc: Emil Velikov <emil.l.velikov@gmail.com>
> > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > ---
> > > >  drivers/gpu/drm/gma500/psb_intel_drv.h  | 19 -------------------
> > > >  drivers/gpu/drm/gma500/psb_intel_sdvo.c | 11 ++++++-----
> > > >  2 files changed, 6 insertions(+), 24 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/gma500/psb_intel_drv.h b/drivers/gpu/drm/gma500/psb_intel_drv.h
> > > > index fb601983cef0..3dd5718c3e31 100644
> > > > --- a/drivers/gpu/drm/gma500/psb_intel_drv.h
> > > > +++ b/drivers/gpu/drm/gma500/psb_intel_drv.h
> > > > @@ -56,25 +56,6 @@
> > > >  #define INTEL_OUTPUT_DISPLAYPORT 9
> > > >  #define INTEL_OUTPUT_EDP 10
> > > >  
> > > > -#define INTEL_MODE_PIXEL_MULTIPLIER_SHIFT (0x0)
> > > > -#define INTEL_MODE_PIXEL_MULTIPLIER_MASK (0xf << INTEL_MODE_PIXEL_MULTIPLIER_SHIFT)
> > > > -
> > > > -static inline void
> > > > -psb_intel_mode_set_pixel_multiplier(struct drm_display_mode *mode,
> > > > -				int multiplier)
> > > > -{
> > > > -	mode->clock *= multiplier;
> > > > -	mode->private_flags |= multiplier;
> > > > -}
> > > > -
> > > > -static inline int
> > > > -psb_intel_mode_get_pixel_multiplier(const struct drm_display_mode *mode)
> > > > -{
> > > > -	return (mode->private_flags & INTEL_MODE_PIXEL_MULTIPLIER_MASK)
> > > > -	       >> INTEL_MODE_PIXEL_MULTIPLIER_SHIFT;
> > > > -}
> > > > -
> > > > -
> > > >  /*
> > > >   * Hold information useally put on the device driver privates here,
> > > >   * since it needs to be shared across multiple of devices drivers privates.
> > > > diff --git a/drivers/gpu/drm/gma500/psb_intel_sdvo.c b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
> > > > index 264d7ad004b4..9e88a37f55e9 100644
> > > > --- a/drivers/gpu/drm/gma500/psb_intel_sdvo.c
> > > > +++ b/drivers/gpu/drm/gma500/psb_intel_sdvo.c
> > > > @@ -132,6 +132,8 @@ struct psb_intel_sdvo {
> > > >  	/* DDC bus used by this SDVO encoder */
> > > >  	uint8_t ddc_bus;
> > > >  
> > > > +	u8 pixel_multiplier;
> > > > +
> > > 
> > > There is really no good reason to use an u8 here.
> > 
> > Wastes less space.
> 
> When there is a good reason - use the size limited variants.
> But in this use case there is no reason to space optimize it.

IMO when it's stuffed into a structure there's no reason not to
optimize it. At some point it all starts to add up.

At least i915 suffers a lot from bloated structures (dev_priv
and atomic state structs being the prime examples) where we
could probably shave dozens if not hundreds of bytes if
everything just used the smallest type possible. In fact
this series does shave dozens of bytes from the crtc state
alone.

> 
> When in the slightly pedantic mode, using u8 is not consistent.
> ddc_bus defined above usese uint8_t.

u8 & co. are preferred in kernel code. Checkpatch even complains when
you use the stdint types. The uint8_t here is some old leftovers.

> 
> 	Sam
> > 
> > > psb_intel_sdvo_get_pixel_multiplier() return an int, so use an int here
> > > too.
> > > 
> > > With this fixed:
> > > Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
> > > 
> > > >  	/* Input timings for adjusted_mode */
> > > >  	struct psb_intel_sdvo_dtd input_dtd;
> > > >  
> > > > @@ -958,7 +960,6 @@ static bool psb_intel_sdvo_mode_fixup(struct drm_encoder *encoder,
> > > >  				  struct drm_display_mode *adjusted_mode)
> > > >  {
> > > >  	struct psb_intel_sdvo *psb_intel_sdvo = to_psb_intel_sdvo(encoder);
> > > > -	int multiplier;
> > > >  
> > > >  	/* We need to construct preferred input timings based on our
> > > >  	 * output timings.  To do that, we have to set the output
> > > > @@ -985,8 +986,9 @@ static bool psb_intel_sdvo_mode_fixup(struct drm_encoder *encoder,
> > > >  	/* Make the CRTC code factor in the SDVO pixel multiplier.  The
> > > >  	 * SDVO device will factor out the multiplier during mode_set.
> > > >  	 */
> > > > -	multiplier = psb_intel_sdvo_get_pixel_multiplier(adjusted_mode);
> > > > -	psb_intel_mode_set_pixel_multiplier(adjusted_mode, multiplier);
> > > > +	psb_intel_sdvo->pixel_multiplier =
> > > > +		psb_intel_sdvo_get_pixel_multiplier(adjusted_mode);
> > > > +	adjusted_mode->clock *= psb_intel_sdvo->pixel_multiplier;
> > > >  
> > > >  	return true;
> > > >  }
> > > > @@ -1002,7 +1004,6 @@ static void psb_intel_sdvo_mode_set(struct drm_encoder *encoder,
> > > >  	u32 sdvox;
> > > >  	struct psb_intel_sdvo_in_out_map in_out;
> > > >  	struct psb_intel_sdvo_dtd input_dtd;
> > > > -	int pixel_multiplier = psb_intel_mode_get_pixel_multiplier(adjusted_mode);
> > > >  	int rate;
> > > >  	int need_aux = IS_MRST(dev) ? 1 : 0;
> > > >  
> > > > @@ -1060,7 +1061,7 @@ static void psb_intel_sdvo_mode_set(struct drm_encoder *encoder,
> > > >  
> > > >  	(void) psb_intel_sdvo_set_input_timing(psb_intel_sdvo, &input_dtd);
> > > >  
> > > > -	switch (pixel_multiplier) {
> > > > +	switch (psb_intel_sdvo->pixel_multiplier) {
> > > >  	default:
> > > >  	case 1: rate = SDVO_CLOCK_RATE_MULT_1X; break;
> > > >  	case 2: rate = SDVO_CLOCK_RATE_MULT_2X; break;
> > > > -- 
> > > > 2.24.1
> > > > 
> > > > _______________________________________________
> > > > dri-devel mailing list
> > > > dri-devel@lists.freedesktop.org
> > > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> > 
> > -- 
> > Ville Syrjälä
> > Intel

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

  reply	other threads:[~2020-04-09 19:50 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-03 20:39 [PATCH v2 00/17] drm: Put drm_display_mode on diet Ville Syrjala
2020-04-03 20:39 ` [PATCH v2 01/17] drm: Nuke mode->hsync Ville Syrjala
2020-04-07 18:30   ` Sam Ravnborg
2020-04-03 20:39 ` [PATCH v2 02/17] drm/i915: Introduce some local intel_dp variables Ville Syrjala
2020-04-03 20:39 ` [PATCH v2 03/17] drm: Nuke mode->vrefresh Ville Syrjala
2020-04-03 20:58   ` Laurent Pinchart
2020-04-04  2:01   ` abhinavk
2020-04-06  8:32     ` Jani Nikula
2020-04-07  1:23       ` abhinavk
2020-04-03 20:39 ` [PATCH v2 04/17] drm/msm/dpu: Stop copying around mode->private_flags Ville Syrjala
2020-04-03 20:39 ` [PATCH v2 05/17] drm: Shrink {width,height}_mm to u16 Ville Syrjala
2020-04-07 18:37   ` Sam Ravnborg
2020-04-03 20:39 ` [PATCH v2 06/17] drm: Shrink mode->type to u8 Ville Syrjala
2020-04-07 18:38   ` Sam Ravnborg
2020-04-03 20:39 ` [PATCH v2 07/17] drm: Make mode->flags u32 Ville Syrjala
2020-04-07 18:38   ` Sam Ravnborg
2020-04-03 20:39 ` [PATCH v2 08/17] drm: Shrink drm_display_mode timings Ville Syrjala
2020-04-07 18:43   ` Sam Ravnborg
2020-04-03 20:40 ` [PATCH v2 09/17] drm: Flatten drm_mode_vrefresh() Ville Syrjala
2020-04-07 18:46   ` Sam Ravnborg
2020-04-03 20:40 ` [PATCH v2 10/17] drm: Shrink mode->private_flags Ville Syrjala
2020-04-07 18:52   ` Sam Ravnborg
2020-04-07 19:10     ` Ville Syrjälä
2020-04-03 20:40 ` [PATCH v2 11/17] drm: pahole struct drm_display_mode Ville Syrjala
2020-04-03 20:40 ` [PATCH v2 12/17] drm/mcde: Use mode->clock instead of reverse calculating it from the vrefresh Ville Syrjala
2020-04-07  7:27   ` Daniel Vetter
2020-04-07 18:53   ` Sam Ravnborg
2020-04-12  0:42   ` Linus Walleij
2020-04-03 20:40 ` [PATCH v2 13/17] drm/i915: Stop using mode->private_flags Ville Syrjala
2020-04-07  7:38   ` Daniel Vetter
2020-04-07 15:20     ` Ville Syrjälä
2020-04-08  9:34       ` [Intel-gfx] " Jani Nikula
2020-04-03 20:40 ` [PATCH v2 14/17] drm/i915: Replace I915_MODE_FLAG_INHERITED with a boolean Ville Syrjala
2020-04-07  7:42   ` Daniel Vetter
2020-04-03 20:40 ` [PATCH v2 15/17] drm/gma500: Stop using mode->private_flags Ville Syrjala
2020-04-07  7:46   ` Daniel Vetter
2020-04-07 18:56   ` Sam Ravnborg
2020-04-07 19:08     ` Ville Syrjälä
2020-04-07 19:35       ` Sam Ravnborg
2020-04-09 19:49         ` Ville Syrjälä [this message]
2020-04-09 19:54           ` Ville Syrjälä
2020-04-09 20:47           ` Sam Ravnborg
2020-04-14 15:11             ` Ville Syrjälä
2020-04-03 20:40 ` [PATCH v2 16/17] drm: Nuke mode->private_flags Ville Syrjala
2020-04-04  1:40   ` abhinavk
2020-04-06  9:11     ` Jani Nikula
2020-04-07  1:26       ` abhinavk
2020-04-07 18:58   ` Sam Ravnborg
2020-04-03 20:40 ` [PATCH v2 17/17] drm: Replace mode->export_head with a boolean Ville Syrjala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200409194952.GZ6112@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=emil.l.velikov@gmail.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=sam@ravnborg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).