Skip to content

Commit f8f6e72

Browse files
committed
drm/omap: Pass along the format info from .fb_create() to drm_helper_mode_fill_fb_struct()
Plumb the format info from .fb_create() all the way to drm_helper_mode_fill_fb_struct() to avoid the redundant lookup. For the fbdev case a manual drm_get_format_info() lookup is needed. The patch is based on the driver parts of the patchset at Link: below, which missed converting the omap driver. Due to the absence of this change in the patchset at Link:, after the Fixed: commit below, omap_framebuffer_init() -> drm_helper_mode_fill_fb_struct() set drm_framebuffer::format incorrectly to NULL, which lead to the !fb->format WARN() in drm_framebuffer_init() and causing framebuffer creation to fail. This patch fixes both of these issues. v2: Amend the commit log mentioning the functional issues the patch fixes. (Tomi) Cc: Ville Syrjälä <[email protected]> Cc: Tomi Valkeinen <[email protected]> Cc: Thomas Zimmermann <[email protected]> Cc: Maarten Lankhorst <[email protected]> Cc: Maxime Ripard <[email protected]> Fixes: 41ab92d ("drm: Make passing of format info to drm_helper_mode_fill_fb_struct() mandatory") Reported-by: Mark Brown <[email protected]> Closes: https://lore.kernel.org/all/[email protected] Link: https://lore.kernel.org/all/[email protected] Tested-by: Mark Brown <[email protected]> Tested-by: Linux Kernel Functional Testing <[email protected]> Acked-by: Alex Deucher <[email protected]> Reviewed-by: Tomi Valkeinen <[email protected]> Signed-off-by: Imre Deak <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent eec8e8c commit f8f6e72

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

drivers/gpu/drm/omapdrm/omap_fb.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
351351
}
352352
}
353353

354-
fb = omap_framebuffer_init(dev, mode_cmd, bos);
354+
fb = omap_framebuffer_init(dev, info, mode_cmd, bos);
355355
if (IS_ERR(fb))
356356
goto error;
357357

@@ -365,9 +365,9 @@ struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
365365
}
366366

367367
struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
368+
const struct drm_format_info *info,
368369
const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos)
369370
{
370-
const struct drm_format_info *format = NULL;
371371
struct omap_framebuffer *omap_fb = NULL;
372372
struct drm_framebuffer *fb = NULL;
373373
unsigned int pitch = mode_cmd->pitches[0];
@@ -377,15 +377,12 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
377377
dev, mode_cmd, mode_cmd->width, mode_cmd->height,
378378
(char *)&mode_cmd->pixel_format);
379379

380-
format = drm_get_format_info(dev, mode_cmd->pixel_format,
381-
mode_cmd->modifier[0]);
382-
383380
for (i = 0; i < ARRAY_SIZE(formats); i++) {
384381
if (formats[i] == mode_cmd->pixel_format)
385382
break;
386383
}
387384

388-
if (!format || i == ARRAY_SIZE(formats)) {
385+
if (i == ARRAY_SIZE(formats)) {
389386
dev_dbg(dev->dev, "unsupported pixel format: %4.4s\n",
390387
(char *)&mode_cmd->pixel_format);
391388
ret = -EINVAL;
@@ -399,31 +396,31 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
399396
}
400397

401398
fb = &omap_fb->base;
402-
omap_fb->format = format;
399+
omap_fb->format = info;
403400
mutex_init(&omap_fb->lock);
404401

405402
/*
406403
* The code below assumes that no format use more than two planes, and
407404
* that the two planes of multiplane formats need the same number of
408405
* bytes per pixel.
409406
*/
410-
if (format->num_planes == 2 && pitch != mode_cmd->pitches[1]) {
407+
if (info->num_planes == 2 && pitch != mode_cmd->pitches[1]) {
411408
dev_dbg(dev->dev, "pitches differ between planes 0 and 1\n");
412409
ret = -EINVAL;
413410
goto fail;
414411
}
415412

416-
if (pitch % format->cpp[0]) {
413+
if (pitch % info->cpp[0]) {
417414
dev_dbg(dev->dev,
418415
"buffer pitch (%u bytes) is not a multiple of pixel size (%u bytes)\n",
419-
pitch, format->cpp[0]);
416+
pitch, info->cpp[0]);
420417
ret = -EINVAL;
421418
goto fail;
422419
}
423420

424-
for (i = 0; i < format->num_planes; i++) {
421+
for (i = 0; i < info->num_planes; i++) {
425422
struct plane *plane = &omap_fb->planes[i];
426-
unsigned int vsub = i == 0 ? 1 : format->vsub;
423+
unsigned int vsub = i == 0 ? 1 : info->vsub;
427424
unsigned int size;
428425

429426
size = pitch * mode_cmd->height / vsub;
@@ -440,7 +437,7 @@ struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
440437
plane->dma_addr = 0;
441438
}
442439

443-
drm_helper_mode_fill_fb_struct(dev, fb, NULL, mode_cmd);
440+
drm_helper_mode_fill_fb_struct(dev, fb, info, mode_cmd);
444441

445442
ret = drm_framebuffer_init(dev, fb, &omap_framebuffer_funcs);
446443
if (ret) {

drivers/gpu/drm/omapdrm/omap_fb.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ struct drm_connector;
1313
struct drm_device;
1414
struct drm_file;
1515
struct drm_framebuffer;
16+
struct drm_format_info;
1617
struct drm_gem_object;
1718
struct drm_mode_fb_cmd2;
1819
struct drm_plane_state;
@@ -23,6 +24,7 @@ struct drm_framebuffer *omap_framebuffer_create(struct drm_device *dev,
2324
struct drm_file *file, const struct drm_format_info *info,
2425
const struct drm_mode_fb_cmd2 *mode_cmd);
2526
struct drm_framebuffer *omap_framebuffer_init(struct drm_device *dev,
27+
const struct drm_format_info *info,
2628
const struct drm_mode_fb_cmd2 *mode_cmd, struct drm_gem_object **bos);
2729
int omap_framebuffer_pin(struct drm_framebuffer *fb);
2830
void omap_framebuffer_unpin(struct drm_framebuffer *fb);

drivers/gpu/drm/omapdrm/omap_fbdev.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ int omap_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
197197
goto fail;
198198
}
199199

200-
fb = omap_framebuffer_init(dev, &mode_cmd, &bo);
200+
fb = omap_framebuffer_init(dev,
201+
drm_get_format_info(dev, mode_cmd.pixel_format,
202+
mode_cmd.modifier[0]),
203+
&mode_cmd, &bo);
201204
if (IS_ERR(fb)) {
202205
dev_err(dev->dev, "failed to allocate fb\n");
203206
/* note: if fb creation failed, we can't rely on fb destroy

0 commit comments

Comments
 (0)