Skip to content

Commit 81112ea

Browse files
committed
drm: Pass the format info to .fb_create()
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 <alexander.deucher@amd.com> Cc: Liviu Dudau <liviu.dudau@arm.com> Cc: Maxime Ripard <mripard@kernel.org> Cc: Russell King <linux@armlinux.org.uk> Cc: Inki Dae <inki.dae@samsung.com> Cc: Seung-Woo Kim <sw0312.kim@samsung.com> Cc: Kyungmin Park <kyungmin.park@samsung.com> Cc: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org> Cc: Philipp Zabel <p.zabel@pengutronix.de> Cc: Rob Clark <robdclark@gmail.com> Cc: Abhinav Kumar <quic_abhinavk@quicinc.com> Cc: Dmitry Baryshkov <lumag@kernel.org> Cc: Sean Paul <sean@poorly.run> Cc: Marijn Suijten <marijn.suijten@somainline.org> Cc: Marek Vasut <marex@denx.de> Cc: Stefan Agner <stefan@agner.ch> Cc: Lyude Paul <lyude@redhat.com> Cc: Danilo Krummrich <dakr@kernel.org> Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Cc: Dave Airlie <airlied@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> Cc: Biju Das <biju.das.jz@bp.renesas.com> Cc: Sandy Huang <hjc@rock-chips.com> Cc: "Heiko Stübner" <heiko@sntech.de> Cc: Andy Yan <andy.yan@rock-chips.com> Cc: Thierry Reding <thierry.reding@gmail.com> Cc: Mikko Perttunen <mperttunen@nvidia.com> Cc: Dave Stevenson <dave.stevenson@raspberrypi.com> Cc: "Maíra Canal" <mcanal@igalia.com> Cc: Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com> Cc: Dmitry Osipenko <dmitry.osipenko@collabora.com> Cc: Gurchetan Singh <gurchetansingh@chromium.org> Cc: Chia-I Wu <olvaffe@gmail.com> Cc: Zack Rusin <zack.rusin@broadcom.com> Cc: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com> Cc: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> Cc: amd-gfx@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org Cc: freedreno@lists.freedesktop.org Cc: nouveau@lists.freedesktop.org Cc: virtualization@lists.linux.dev Cc: spice-devel@lists.freedesktop.org Cc: linux-renesas-soc@vger.kernel.org Cc: linux-tegra@vger.kernel.org Cc: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com> Acked-by: Liviu Dudau <liviu.dudau@arm.com> Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250701090722.13645-5-ville.syrjala@linux.intel.com
1 parent d5d6340 commit 81112ea

38 files changed

Lines changed: 59 additions & 49 deletions

drivers/gpu/drm/amd/amdgpu/amdgpu_display.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,7 @@ static int amdgpu_display_framebuffer_init(struct drm_device *dev,
12971297
struct drm_framebuffer *
12981298
amdgpu_display_user_framebuffer_create(struct drm_device *dev,
12991299
struct drm_file *file_priv,
1300+
const struct drm_format_info *info,
13001301
const struct drm_mode_fb_cmd2 *mode_cmd)
13011302
{
13021303
struct amdgpu_framebuffer *amdgpu_fb;

drivers/gpu/drm/amd/amdgpu/amdgpu_display.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ uint32_t amdgpu_display_supported_domains(struct amdgpu_device *adev,
4444
struct drm_framebuffer *
4545
amdgpu_display_user_framebuffer_create(struct drm_device *dev,
4646
struct drm_file *file_priv,
47+
const struct drm_format_info *info,
4748
const struct drm_mode_fb_cmd2 *mode_cmd);
4849
const struct drm_format_info *
4950
amdgpu_lookup_format_info(u32 format, uint64_t modifier);

drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ komeda_fb_none_afbc_size_check(struct komeda_dev *mdev, struct komeda_fb *kfb,
157157

158158
struct drm_framebuffer *
159159
komeda_fb_create(struct drm_device *dev, struct drm_file *file,
160+
const struct drm_format_info *info,
160161
const struct drm_mode_fb_cmd2 *mode_cmd)
161162
{
162163
struct komeda_dev *mdev = dev->dev_private;

drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ struct komeda_fb {
3737

3838
struct drm_framebuffer *
3939
komeda_fb_create(struct drm_device *dev, struct drm_file *file,
40+
const struct drm_format_info *info,
4041
const struct drm_mode_fb_cmd2 *mode_cmd);
4142
int komeda_fb_check_src_coords(const struct komeda_fb *kfb,
4243
u32 src_x, u32 src_y, u32 src_w, u32 src_h);

drivers/gpu/drm/arm/malidp_drv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,14 +377,15 @@ malidp_verify_afbc_framebuffer(struct drm_device *dev, struct drm_file *file,
377377

378378
static struct drm_framebuffer *
379379
malidp_fb_create(struct drm_device *dev, struct drm_file *file,
380+
const struct drm_format_info *info,
380381
const struct drm_mode_fb_cmd2 *mode_cmd)
381382
{
382383
if (mode_cmd->modifier[0]) {
383384
if (!malidp_verify_afbc_framebuffer(dev, file, mode_cmd))
384385
return ERR_PTR(-EINVAL);
385386
}
386387

387-
return drm_gem_fb_create(dev, file, mode_cmd);
388+
return drm_gem_fb_create(dev, file, info, mode_cmd);
388389
}
389390

390391
static const struct drm_mode_config_funcs malidp_mode_config_funcs = {

drivers/gpu/drm/armada/armada_fb.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,9 @@ struct armada_framebuffer *armada_framebuffer_create(struct drm_device *dev,
8484
}
8585

8686
struct drm_framebuffer *armada_fb_create(struct drm_device *dev,
87-
struct drm_file *dfile, const struct drm_mode_fb_cmd2 *mode)
87+
struct drm_file *dfile, const struct drm_format_info *info,
88+
const struct drm_mode_fb_cmd2 *mode)
8889
{
89-
const struct drm_format_info *info = drm_get_format_info(dev,
90-
mode->pixel_format,
91-
mode->modifier[0]);
9290
struct armada_gem_object *obj;
9391
struct armada_framebuffer *dfb;
9492
int ret;

drivers/gpu/drm/armada/armada_fb.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ struct armada_framebuffer {
1919
struct armada_framebuffer *armada_framebuffer_create(struct drm_device *,
2020
const struct drm_mode_fb_cmd2 *, struct armada_gem_object *);
2121
struct drm_framebuffer *armada_fb_create(struct drm_device *dev,
22-
struct drm_file *dfile, const struct drm_mode_fb_cmd2 *mode);
22+
struct drm_file *dfile, const struct drm_format_info *info,
23+
const struct drm_mode_fb_cmd2 *mode);
2324
#endif

drivers/gpu/drm/drm_framebuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ drm_internal_framebuffer_create(struct drm_device *dev,
302302
if (ret)
303303
return ERR_PTR(ret);
304304

305-
fb = dev->mode_config.funcs->fb_create(dev, file_priv, r);
305+
fb = dev->mode_config.funcs->fb_create(dev, file_priv, info, r);
306306
if (IS_ERR(fb)) {
307307
drm_dbg_kms(dev, "could not create framebuffer\n");
308308
return fb;

drivers/gpu/drm/drm_gem_framebuffer_helper.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ static const struct drm_framebuffer_funcs drm_gem_fb_funcs = {
264264
* &drm_mode_config_funcs.fb_create callback
265265
* @dev: DRM device
266266
* @file: DRM file that holds the GEM handle(s) backing the framebuffer
267+
* @info: pixel format information
267268
* @mode_cmd: Metadata from the userspace framebuffer creation request
268269
*
269270
* This function creates a new framebuffer object described by
@@ -283,6 +284,7 @@ static const struct drm_framebuffer_funcs drm_gem_fb_funcs = {
283284
*/
284285
struct drm_framebuffer *
285286
drm_gem_fb_create(struct drm_device *dev, struct drm_file *file,
287+
const struct drm_format_info *info,
286288
const struct drm_mode_fb_cmd2 *mode_cmd)
287289
{
288290
return drm_gem_fb_create_with_funcs(dev, file, mode_cmd,
@@ -301,6 +303,7 @@ static const struct drm_framebuffer_funcs drm_gem_fb_funcs_dirtyfb = {
301303
* &drm_mode_config_funcs.fb_create callback
302304
* @dev: DRM device
303305
* @file: DRM file that holds the GEM handle(s) backing the framebuffer
306+
* @info: pixel format information
304307
* @mode_cmd: Metadata from the userspace framebuffer creation request
305308
*
306309
* This function creates a new framebuffer object described by
@@ -321,6 +324,7 @@ static const struct drm_framebuffer_funcs drm_gem_fb_funcs_dirtyfb = {
321324
*/
322325
struct drm_framebuffer *
323326
drm_gem_fb_create_with_dirty(struct drm_device *dev, struct drm_file *file,
327+
const struct drm_format_info *info,
324328
const struct drm_mode_fb_cmd2 *mode_cmd)
325329
{
326330
return drm_gem_fb_create_with_funcs(dev, file, mode_cmd,

drivers/gpu/drm/exynos/exynos_drm_fb.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,9 @@ exynos_drm_framebuffer_init(struct drm_device *dev,
9494

9595
static struct drm_framebuffer *
9696
exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv,
97+
const struct drm_format_info *info,
9798
const struct drm_mode_fb_cmd2 *mode_cmd)
9899
{
99-
const struct drm_format_info *info = drm_get_format_info(dev,
100-
mode_cmd->pixel_format,
101-
mode_cmd->modifier[0]);
102100
struct exynos_drm_gem *exynos_gem[MAX_FB_BUFFER];
103101
struct drm_framebuffer *fb;
104102
int i;

0 commit comments

Comments
 (0)