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

drm/ingenic: Use the highest possible DMA burst size

Until now, when running at the maximum resolution of 1280x720 at 32bpp
on the JZ4770 SoC the output was garbled, the X/Y position of the
top-left corner of the framebuffer warping to a random position with
the whole image being offset accordingly, every time a new frame was
being submitted.

This problem can be eliminated by using a bigger burst size for the DMA.

Set in each soc_info structure the maximum burst size supported by the
corresponding SoC, and use it in the driver.

Set the new value using regmap_update_bits() instead of
regmap_set_bits(), since we do want to override the old value of the
burst size. (Note that regmap_set_bits() wasn't really valid before for
the same reason, but it never seemed to be a problem).

Cc: <stable@vger.kernel.org>
Fixes: 90b86fcc47b4 ("DRM: Add KMS driver for the Ingenic JZ47xx SoCs")
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Link: https://patchwork.freedesktop.org/patch/msgid/20220702230727.66704-1-paul@crapouillou.net
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Tested-by: Christophe Branchereau <cbranchereau@gmail.com>

+11 -2
+8 -2
drivers/gpu/drm/ingenic/ingenic-drm-drv.c
··· 70 70 bool map_noncoherent; 71 71 bool use_extended_hwdesc; 72 72 bool plane_f0_not_working; 73 + u32 max_burst; 73 74 unsigned int max_width, max_height; 74 75 const u32 *formats_f0, *formats_f1; 75 76 unsigned int num_formats_f0, num_formats_f1; ··· 320 319 regmap_write(priv->map, JZ_REG_LCD_REV, mode->htotal << 16); 321 320 } 322 321 323 - regmap_set_bits(priv->map, JZ_REG_LCD_CTRL, 324 - JZ_LCD_CTRL_OFUP | JZ_LCD_CTRL_BURST_16); 322 + regmap_update_bits(priv->map, JZ_REG_LCD_CTRL, 323 + JZ_LCD_CTRL_OFUP | JZ_LCD_CTRL_BURST_MASK, 324 + JZ_LCD_CTRL_OFUP | priv->soc_info->max_burst); 325 325 326 326 /* 327 327 * IPU restart - specify how much time the LCDC will wait before ··· 1521 1519 .map_noncoherent = false, 1522 1520 .max_width = 800, 1523 1521 .max_height = 600, 1522 + .max_burst = JZ_LCD_CTRL_BURST_16, 1524 1523 .formats_f1 = jz4740_formats, 1525 1524 .num_formats_f1 = ARRAY_SIZE(jz4740_formats), 1526 1525 /* JZ4740 has only one plane */ ··· 1533 1530 .map_noncoherent = false, 1534 1531 .max_width = 800, 1535 1532 .max_height = 600, 1533 + .max_burst = JZ_LCD_CTRL_BURST_16, 1536 1534 .formats_f1 = jz4725b_formats_f1, 1537 1535 .num_formats_f1 = ARRAY_SIZE(jz4725b_formats_f1), 1538 1536 .formats_f0 = jz4725b_formats_f0, ··· 1546 1542 .map_noncoherent = true, 1547 1543 .max_width = 1280, 1548 1544 .max_height = 720, 1545 + .max_burst = JZ_LCD_CTRL_BURST_64, 1549 1546 .formats_f1 = jz4770_formats_f1, 1550 1547 .num_formats_f1 = ARRAY_SIZE(jz4770_formats_f1), 1551 1548 .formats_f0 = jz4770_formats_f0, ··· 1561 1556 .plane_f0_not_working = true, /* REVISIT */ 1562 1557 .max_width = 4096, 1563 1558 .max_height = 2048, 1559 + .max_burst = JZ_LCD_CTRL_BURST_64, 1564 1560 .formats_f1 = jz4770_formats_f1, 1565 1561 .num_formats_f1 = ARRAY_SIZE(jz4770_formats_f1), 1566 1562 .formats_f0 = jz4770_formats_f0,
+3
drivers/gpu/drm/ingenic/ingenic-drm.h
··· 106 106 #define JZ_LCD_CTRL_BURST_4 (0x0 << 28) 107 107 #define JZ_LCD_CTRL_BURST_8 (0x1 << 28) 108 108 #define JZ_LCD_CTRL_BURST_16 (0x2 << 28) 109 + #define JZ_LCD_CTRL_BURST_32 (0x3 << 28) 110 + #define JZ_LCD_CTRL_BURST_64 (0x4 << 28) 111 + #define JZ_LCD_CTRL_BURST_MASK (0x7 << 28) 109 112 #define JZ_LCD_CTRL_RGB555 BIT(27) 110 113 #define JZ_LCD_CTRL_OFUP BIT(26) 111 114 #define JZ_LCD_CTRL_FRC_GRAYSCALE_16 (0x0 << 24)