Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm: Look up the format info earlier

Look up the format info already in 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).

v2: Fix commit msg (Thomas)

Reviewed-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250701090722.13645-4-ville.syrjala@linux.intel.com

+13 -12
+13 -12
drivers/gpu/drm/drm_framebuffer.c
··· 153 153 } 154 154 155 155 static int framebuffer_check(struct drm_device *dev, 156 + const struct drm_format_info *info, 156 157 const struct drm_mode_fb_cmd2 *r) 157 158 { 158 - const struct drm_format_info *info; 159 159 int i; 160 - 161 - /* check if the format is supported at all */ 162 - if (!__drm_format_info(r->pixel_format)) { 163 - drm_dbg_kms(dev, "bad framebuffer format %p4cc\n", 164 - &r->pixel_format); 165 - return -EINVAL; 166 - } 167 160 168 161 if (r->width == 0) { 169 162 drm_dbg_kms(dev, "bad framebuffer width %u\n", r->width); ··· 167 174 drm_dbg_kms(dev, "bad framebuffer height %u\n", r->height); 168 175 return -EINVAL; 169 176 } 170 - 171 - /* now let the driver pick its own format info */ 172 - info = drm_get_format_info(dev, r->pixel_format, r->modifier[0]); 173 177 174 178 for (i = 0; i < info->num_planes; i++) { 175 179 unsigned int width = drm_format_info_plane_width(info, r->width, i); ··· 262 272 struct drm_file *file_priv) 263 273 { 264 274 struct drm_mode_config *config = &dev->mode_config; 275 + const struct drm_format_info *info; 265 276 struct drm_framebuffer *fb; 266 277 int ret; 267 278 ··· 288 297 return ERR_PTR(-EINVAL); 289 298 } 290 299 291 - ret = framebuffer_check(dev, r); 300 + /* check if the format is supported at all */ 301 + if (!__drm_format_info(r->pixel_format)) { 302 + drm_dbg_kms(dev, "bad framebuffer format %p4cc\n", 303 + &r->pixel_format); 304 + return ERR_PTR(-EINVAL); 305 + } 306 + 307 + /* now let the driver pick its own format info */ 308 + info = drm_get_format_info(dev, r->pixel_format, r->modifier[0]); 309 + 310 + ret = framebuffer_check(dev, info, r); 292 311 if (ret) 293 312 return ERR_PTR(ret); 294 313