Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
	intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 03/19] drm: Look up the format info earlier
Date: Fri, 11 Apr 2025 10:01:58 +0300	[thread overview]
Message-ID: <Z_i-Zniclef5dkUD@intel.com> (raw)
In-Reply-To: <20250410193302.GC27834@pendragon.ideasonboard.com>

On Thu, Apr 10, 2025 at 10:33:02PM +0300, Laurent Pinchart wrote:
> Hi Ville,
> 
> Thank you for the patch.
> 
> On Thu, Apr 10, 2025 at 07:32:02PM +0300, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Looks up the format info in already drm_internal_framebuffer_create()
> > so that we can later pass it along to .fb_create(). Currently various
> > drivers are doing additional lookups in their .fb_create()
> > implementations, and these lookups are rather expensive now (given
> > how many different pixel formats we have).
> 
> That's a separate issue, but would it be worth using a data structure
> that supports more efficient lookup ?

I think the obvious solution would be to to just sort the array
and use a binary search. Ideally we'd get the compiler to do that
for us at build time and then get rid of the unsorted array entirely,
but sadly we can't do that in C. The alternative of keeping the array
sorted by hand sounds very annoying (at least without having a way
to validate that it is correctly sorted at build time).

> 
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
> 
> > ---
> >  drivers/gpu/drm/drm_framebuffer.c | 25 +++++++++++++------------
> >  1 file changed, 13 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c
> > index 18a0267e374e..ae09ef6977b2 100644
> > --- a/drivers/gpu/drm/drm_framebuffer.c
> > +++ b/drivers/gpu/drm/drm_framebuffer.c
> > @@ -153,18 +153,11 @@ int drm_mode_addfb_ioctl(struct drm_device *dev,
> >  }
> >  
> >  static int framebuffer_check(struct drm_device *dev,
> > +			     const struct drm_format_info *info,
> >  			     const struct drm_mode_fb_cmd2 *r)
> >  {
> > -	const struct drm_format_info *info;
> >  	int i;
> >  
> > -	/* check if the format is supported at all */
> > -	if (!__drm_format_info(r->pixel_format)) {
> > -		drm_dbg_kms(dev, "bad framebuffer format %p4cc\n",
> > -			    &r->pixel_format);
> > -		return -EINVAL;
> > -	}
> > -
> >  	if (r->width == 0) {
> >  		drm_dbg_kms(dev, "bad framebuffer width %u\n", r->width);
> >  		return -EINVAL;
> > @@ -175,9 +168,6 @@ static int framebuffer_check(struct drm_device *dev,
> >  		return -EINVAL;
> >  	}
> >  
> > -	/* now let the driver pick its own format info */
> > -	info = drm_get_format_info(dev, r->pixel_format, r->modifier[0]);
> > -
> >  	for (i = 0; i < info->num_planes; i++) {
> >  		unsigned int width = drm_format_info_plane_width(info, r->width, i);
> >  		unsigned int height = drm_format_info_plane_height(info, r->height, i);
> > @@ -272,6 +262,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
> >  				struct drm_file *file_priv)
> >  {
> >  	struct drm_mode_config *config = &dev->mode_config;
> > +	const struct drm_format_info *info;
> >  	struct drm_framebuffer *fb;
> >  	int ret;
> >  
> > @@ -297,7 +288,17 @@ drm_internal_framebuffer_create(struct drm_device *dev,
> >  		return ERR_PTR(-EINVAL);
> >  	}
> >  
> > -	ret = framebuffer_check(dev, r);
> > +	/* check if the format is supported at all */
> > +	if (!__drm_format_info(r->pixel_format)) {
> > +		drm_dbg_kms(dev, "bad framebuffer format %p4cc\n",
> > +			    &r->pixel_format);
> > +		return ERR_PTR(-EINVAL);
> > +	}
> > +
> > +	/* now let the driver pick its own format info */
> > +	info = drm_get_format_info(dev, r->pixel_format, r->modifier[0]);
> > +
> > +	ret = framebuffer_check(dev, info, r);
> >  	if (ret)
> >  		return ERR_PTR(ret);
> >  
> 
> -- 
> Regards,
> 
> Laurent Pinchart

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2025-04-11  7:02 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 16:31 [PATCH 00/19] drm: Eliminate redundant drm_format_info lookups Ville Syrjala
2025-04-10 16:32 ` [PATCH 01/19] drm: Pass pixel_format+modifier to .get_format_info() Ville Syrjala
2025-04-10 19:27   ` Laurent Pinchart
2025-04-11  6:47     ` Ville Syrjälä
2025-04-11 19:19   ` [PATCH v2 " Ville Syrjala
2025-04-10 16:32 ` [PATCH 02/19] drm: Pass pixel_format+modifier directly to drm_get_format_info() Ville Syrjala
2025-04-10 19:31   ` Laurent Pinchart
2025-04-10 19:43   ` kernel test robot
2025-04-11  7:23   ` Thomas Zimmermann
2025-04-11 19:27   ` [PATCH v2 " Ville Syrjala
2025-04-10 16:32 ` [PATCH 03/19] drm: Look up the format info earlier Ville Syrjala
2025-04-10 19:33   ` Laurent Pinchart
2025-04-11  7:01     ` Ville Syrjälä [this message]
2025-04-11  7:18   ` Thomas Zimmermann
2025-04-11 19:27   ` [PATCH v2 " Ville Syrjala
2025-04-10 16:32 ` [PATCH 04/19] drm: Pass the format info to .fb_create() Ville Syrjala
2025-04-10 19:37   ` Laurent Pinchart
2025-04-10 21:26   ` kernel test robot
2025-04-11  6:36   ` Geert Uytterhoeven
2025-04-11 19:29   ` [PATCH v2 " Ville Syrjala
2025-04-10 16:32 ` [PATCH 05/19] drm: Allow the caller to pass in the format info to drm_helper_mode_fill_fb_struct() Ville Syrjala
2025-04-10 19:38   ` Laurent Pinchart
2025-04-10 16:32 ` [PATCH 06/19] drm/malidp: Pass along the format info from .fb_create() malidp_verify_afbc_framebuffer_size() Ville Syrjala
2025-04-10 16:32 ` [PATCH 07/19] drm/gem: Pass along the format info from .fb_create() to drm_helper_mode_fill_fb_struct() Ville Syrjala
2025-04-10 19:39   ` Laurent Pinchart
2025-04-10 22:58   ` kernel test robot
2025-04-11 19:31   ` [PATCH v2 " Ville Syrjala
2025-04-10 16:32 ` [PATCH 08/19] drm/gem/afbc: Eliminate redundant drm_get_format_info() Ville Syrjala
2025-04-10 16:32 ` [PATCH 09/19] drm/amdgpu: Pass along the format info from .fb_create() to drm_helper_mode_fill_fb_struct() Ville Syrjala
2025-04-10 16:32 ` [PATCH 10/19] drm/armada: " Ville Syrjala
2025-04-10 16:32 ` [PATCH 11/19] drm/exynos: " Ville Syrjala
2025-04-10 16:32 ` [PATCH 12/19] drm/gma500: " Ville Syrjala
2025-04-10 16:32 ` [PATCH 13/19] drm/i915: " Ville Syrjala
2025-04-10 16:32 ` [PATCH 14/19] drm/komeda: " Ville Syrjala
2025-04-10 16:32 ` [PATCH 15/19] drm/msm: " Ville Syrjala
2025-04-10 19:28   ` Dmitry Baryshkov
2025-04-10 16:32 ` [PATCH 16/19] drm/tegra: " Ville Syrjala
2025-04-10 16:32 ` [PATCH 17/19] drm/virtio: " Ville Syrjala
2025-04-16  6:44   ` Dmitry Osipenko
2025-04-10 16:32 ` [PATCH 18/19] drm/vmwgfx: " Ville Syrjala
2025-04-10 16:32 ` [PATCH 19/19] drm: Make passing of format info to drm_helper_mode_fill_fb_struct() mandatory Ville Syrjala
2025-04-10 19:40   ` Laurent Pinchart
2025-04-10 18:46 ` ✓ CI.Patch_applied: success for drm: Eliminate redundant drm_format_info lookups Patchwork
2025-04-10 18:47 ` ✗ CI.checkpatch: warning " Patchwork
2025-04-10 18:48 ` ✓ CI.KUnit: success " Patchwork
2025-04-10 19:03 ` ✓ CI.Build: " Patchwork
2025-04-10 19:05 ` ✓ CI.Hooks: " Patchwork
2025-04-10 19:06 ` ✗ CI.checksparse: warning " Patchwork
2025-04-10 19:51 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-04-11  0:20 ` ✗ Xe.CI.Full: " Patchwork
2025-04-11  7:30 ` [PATCH 00/19] " Thomas Zimmermann
2025-04-11 19:54 ` ✓ CI.Patch_applied: success for drm: Eliminate redundant drm_format_info lookups (rev2) Patchwork
2025-04-11 19:54 ` ✗ CI.checkpatch: warning " Patchwork
2025-04-11 19:56 ` ✓ CI.KUnit: success " Patchwork
2025-04-11 20:04 ` ✓ CI.Build: " Patchwork
2025-04-11 20:06 ` ✓ CI.Hooks: " Patchwork
2025-04-11 20:08 ` ✗ CI.checksparse: warning " Patchwork
2025-04-11 20:58 ` ✓ Xe.CI.BAT: success " Patchwork
2025-04-11 22:07 ` ✓ CI.Patch_applied: success for drm: Eliminate redundant drm_format_info lookups (rev6) Patchwork
2025-04-11 22:08 ` ✗ CI.checkpatch: warning " Patchwork
2025-04-11 22:09 ` ✓ CI.KUnit: success " Patchwork
2025-04-11 22:18 ` ✓ CI.Build: " Patchwork
2025-04-11 22:20 ` ✓ CI.Hooks: " Patchwork
2025-04-11 22:22 ` ✗ CI.checksparse: warning " Patchwork
2025-04-11 22:48 ` ✓ Xe.CI.BAT: success " Patchwork
2025-04-11 23:03 ` ✗ Xe.CI.Full: failure for drm: Eliminate redundant drm_format_info lookups (rev2) Patchwork
2025-04-12  0:56 ` ✗ Xe.CI.Full: failure for drm: Eliminate redundant drm_format_info lookups (rev6) Patchwork
2025-07-15 18:21 ` [PATCH 00/19] drm: Eliminate redundant drm_format_info lookups Alex Deucher
2025-07-15 18:22   ` Alex Deucher

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=Z_i-Zniclef5dkUD@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=laurent.pinchart@ideasonboard.com \
    /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