On Tue, Jul 01, 2025 at 10:18:01PM +0300, Laurent Pinchart wrote:
> Hi Ville,
> 
> Thank you for the patch.
> 
> On Tue, Jul 01, 2025 at 12:07:07PM +0300, Ville Syrjala wrote:
> > From: Ville Syrjälä <[email protected]>
> > 
> > Pass along the format information from the top to .fb_create()
> > so that we can avoid redundant (and somewhat expensive) lookups
> > in the drivers.
> > 
> > Done with cocci (with some manual fixups):
> > @@
> > identifier func =~ ".*create.*";
> > identifier dev, file, mode_cmd;
> > @@
> > struct drm_framebuffer *func(
> >        struct drm_device *dev,
> >        struct drm_file *file,
> > +      const struct drm_format_info *info,
> >        const struct drm_mode_fb_cmd2 *mode_cmd)
> > {
> > ...
> > (
> > - const struct drm_format_info *info = drm_get_format_info(...);
> > |
> > - const struct drm_format_info *info;
> > ...
> > - info = drm_get_format_info(...);
> > )
> > <...
> > - if (!info)
> > -    return ...;
> > ...>
> > }
> > 
> > @@
> > identifier func =~ ".*create.*";
> > identifier dev, file, mode_cmd;
> > @@
> > struct drm_framebuffer *func(
> >        struct drm_device *dev,
> >        struct drm_file *file,
> > +      const struct drm_format_info *info,
> >        const struct drm_mode_fb_cmd2 *mode_cmd)
> > {
> > ...
> > }
> > 
> > @find@
> > identifier fb_create_func =~ ".*create.*";
> > identifier dev, file, mode_cmd;
> > @@
> > struct drm_framebuffer *fb_create_func(
> >        struct drm_device *dev,
> >        struct drm_file *file,
> > +      const struct drm_format_info *info,
> >        const struct drm_mode_fb_cmd2 *mode_cmd);
> > 
> > @@
> > identifier find.fb_create_func;
> > expression dev, file, mode_cmd;
> > @@
> > fb_create_func(dev, file
> > +          ,info
> >            ,mode_cmd)
> > 
> > @@
> > expression dev, file, mode_cmd;
> > @@
> > drm_gem_fb_create(dev, file
> > +          ,info
> >            ,mode_cmd)
> > 
> > @@
> > expression dev, file, mode_cmd;
> > @@
> > drm_gem_fb_create_with_dirty(dev, file
> > +          ,info
> >            ,mode_cmd)
> > 
> > @@
> > expression dev, file_priv, mode_cmd;
> > identifier info, fb;
> > @@
> > info = drm_get_format_info(...);
> > ...
> > fb = dev->mode_config.funcs->fb_create(dev, file_priv
> > +                                      ,info
> >                                        ,mode_cmd);
> > 
> > @@
> > identifier dev, file_priv, mode_cmd;
> > @@
> > struct drm_mode_config_funcs {
> > ...
> > struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
> >                                      struct drm_file *file_priv,
> > +                                     const struct drm_format_info *info,
> >                                      const struct drm_mode_fb_cmd2 
> > *mode_cmd);
> > ...
> > };
> > 
> > v2: Fix kernel docs (Laurent)
> >     Fix commit msg (Geert)
> > 
> > Cc: Alex Deucher <[email protected]>
> > Cc: Liviu Dudau <[email protected]>
> > Cc: Maxime Ripard <[email protected]>
> > Cc: Russell King <[email protected]>
> > Cc: Inki Dae <[email protected]>
> > Cc: Seung-Woo Kim <[email protected]>
> > Cc: Kyungmin Park <[email protected]>
> > Cc: Patrik Jakobsson <[email protected]>
> > Cc: Chun-Kuang Hu <[email protected]>
> > Cc: Philipp Zabel <[email protected]>
> > Cc: Rob Clark <[email protected]>
> > Cc: Abhinav Kumar <[email protected]>
> > Cc: Dmitry Baryshkov <[email protected]>
> > Cc: Sean Paul <[email protected]>
> > Cc: Marijn Suijten <[email protected]>
> > Cc: Marek Vasut <[email protected]>
> > Cc: Stefan Agner <[email protected]>
> > Cc: Lyude Paul <[email protected]>
> > Cc: Danilo Krummrich <[email protected]>
> > Cc: Tomi Valkeinen <[email protected]>
> > Cc: Dave Airlie <[email protected]>
> > Cc: Gerd Hoffmann <[email protected]>
> > Cc: Kieran Bingham <[email protected]>
> > Cc: Biju Das <[email protected]>
> > Cc: Sandy Huang <[email protected]>
> > Cc: "Heiko Stübner" <[email protected]>
> > Cc: Andy Yan <[email protected]>
> > Cc: Thierry Reding <[email protected]>
> > Cc: Mikko Perttunen <[email protected]>
> > Cc: Dave Stevenson <[email protected]>
> > Cc: "Maíra Canal" <[email protected]>
> > Cc: Raspberry Pi Kernel Maintenance <[email protected]>
> > Cc: Dmitry Osipenko <[email protected]>
> > Cc: Gurchetan Singh <[email protected]>
> > Cc: Chia-I Wu <[email protected]>
> > Cc: Zack Rusin <[email protected]>
> > Cc: Broadcom internal kernel review list 
> > <[email protected]>
> > Cc: Oleksandr Andrushchenko <[email protected]>
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: Laurent Pinchart <[email protected]>
> > Reviewed-by: Geert Uytterhoeven <[email protected]>
> > Reviewed-by: Thomas Zimmermann <[email protected]>
> > Signed-off-by: Ville Syrjälä <[email protected]>
> > ---
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c            |  1 +
> >  drivers/gpu/drm/amd/amdgpu/amdgpu_display.h            |  1 +
> >  .../gpu/drm/arm/display/komeda/komeda_framebuffer.c    |  1 +
> >  .../gpu/drm/arm/display/komeda/komeda_framebuffer.h    |  1 +
> >  drivers/gpu/drm/arm/malidp_drv.c                       |  3 ++-
> >  drivers/gpu/drm/armada/armada_fb.c                     |  6 ++----
> >  drivers/gpu/drm/armada/armada_fb.h                     |  3 ++-
> >  drivers/gpu/drm/drm_framebuffer.c                      |  2 +-
> >  drivers/gpu/drm/drm_gem_framebuffer_helper.c           |  4 ++++
> >  drivers/gpu/drm/exynos/exynos_drm_fb.c                 |  4 +---
> >  drivers/gpu/drm/gma500/framebuffer.c                   |  1 +
> >  drivers/gpu/drm/i915/display/intel_fb.c                |  1 +
> >  drivers/gpu/drm/i915/display/intel_fb.h                |  1 +
> >  drivers/gpu/drm/ingenic/ingenic-drm-drv.c              |  5 +++--
> >  drivers/gpu/drm/mediatek/mtk_drm_drv.c                 |  7 ++-----
> >  drivers/gpu/drm/msm/msm_drv.h                          |  3 ++-
> >  drivers/gpu/drm/msm/msm_fb.c                           |  6 ++----
> >  drivers/gpu/drm/mxsfb/mxsfb_drv.c                      | 10 ++--------
> >  drivers/gpu/drm/nouveau/nouveau_display.c              |  1 +
> >  drivers/gpu/drm/nouveau/nouveau_display.h              |  1 +
> >  drivers/gpu/drm/omapdrm/omap_fb.c                      |  6 ++----
> >  drivers/gpu/drm/omapdrm/omap_fb.h                      |  3 ++-
> >  drivers/gpu/drm/qxl/qxl_display.c                      |  1 +
> >  drivers/gpu/drm/radeon/radeon_display.c                |  1 +
> >  drivers/gpu/drm/renesas/rcar-du/rcar_du_kms.c          |  3 ++-
> >  drivers/gpu/drm/renesas/rz-du/rzg2l_du_kms.c           |  3 ++-
> >  drivers/gpu/drm/renesas/shmobile/shmob_drm_kms.c       |  3 ++-
> >  drivers/gpu/drm/rockchip/rockchip_drm_fb.c             |  7 +------
> >  drivers/gpu/drm/tegra/drm.h                            |  1 +
> >  drivers/gpu/drm/tegra/fb.c                             |  4 +---
> >  drivers/gpu/drm/tests/drm_framebuffer_test.c           |  1 +
> >  drivers/gpu/drm/vc4/vc4_kms.c                          |  3 ++-
> >  drivers/gpu/drm/virtio/virtgpu_display.c               |  1 +
> >  drivers/gpu/drm/vmwgfx/vmwgfx_kms.c                    |  1 +
> >  drivers/gpu/drm/xen/xen_drm_front_kms.c                |  1 +
> >  drivers/gpu/drm/xlnx/zynqmp_kms.c                      |  3 ++-
> >  include/drm/drm_gem_framebuffer_helper.h               |  3 +++
> >  include/drm/drm_mode_config.h                          |  1 +
> >  38 files changed, 59 insertions(+), 49 deletions(-)
> 
> [snip]
> 
> > diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> > index e971e1b8a850..2e848b816218 100644
> > --- a/include/drm/drm_mode_config.h
> > +++ b/include/drm/drm_mode_config.h
> > @@ -82,6 +82,7 @@ struct drm_mode_config_funcs {
> >      */
> 
> It would be nice to document the new parameter here. With that
> addressed,

None of the existing parameters are documented (for any of the
mode_config hooks actually), so I think we'd need a separate
patch to deal with this.

> 
> Reviewed-by: Laurent Pinchart <[email protected]>
> 
> >     struct drm_framebuffer *(*fb_create)(struct drm_device *dev,
> >                                          struct drm_file *file_priv,
> > +                                        const struct drm_format_info *info,
> >                                          const struct drm_mode_fb_cmd2 
> > *mode_cmd);
> >  
> >     /**
> 
> -- 
> Regards,
> 
> Laurent Pinchart

-- 
Ville Syrjälä
Intel

Reply via email to