On 25/03/2025 11:31, Thomas Zimmermann wrote:
For ease of implementation, existing line-conversion functions
for 8-bit formats write each pixel individually. Optimize the
performance by writing mulitple pixels in a single 32-bit store.
With the commit message typo fixed, mulitple => multiple
Reviewed-by: Jocelyn Falempe <jfale...@redhat.com>
Signed-off-by: Thomas Zimmermann <tzimmerm...@suse.de>
---
drivers/gpu/drm/drm_format_helper.c | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_format_helper.c
b/drivers/gpu/drm/drm_format_helper.c
index 66137df85725..73833db28c3c 100644
--- a/drivers/gpu/drm/drm_format_helper.c
+++ b/drivers/gpu/drm/drm_format_helper.c
@@ -250,10 +250,31 @@ static __always_inline void drm_fb_xfrm_line_32to8(void
*dbuf, const void *sbuf,
unsigned int pixels,
u32 (*xfrm_pixel)(u32))
{
- u8 *dbuf8 = dbuf;
+ __le32 *dbuf32 = dbuf;
+ u8 *dbuf8;
const __le32 *sbuf32 = sbuf;
const __le32 *send32 = sbuf32 + pixels;
+ /* write 4 pixels at once */
+ send32 -= pixels & GENMASK(1, 0);
+ while (sbuf32 < send32) {
+ u32 pix[4] = {
+ le32_to_cpup(sbuf32++),
+ le32_to_cpup(sbuf32++),
+ le32_to_cpup(sbuf32++),
+ le32_to_cpup(sbuf32++),
+ };
+ /* write output bytes in reverse order for little endianness */
+ u32 val32 = xfrm_pixel(pix[0]) |
+ (xfrm_pixel(pix[1]) << 8) |
+ (xfrm_pixel(pix[2]) << 16) |
+ (xfrm_pixel(pix[3]) << 24);
+ *dbuf32++ = cpu_to_le32(val32);
+ }
+ send32 += pixels & GENMASK(1, 0);
+
+ /* write trailing pixels */
+ dbuf8 = (u8 __force *)dbuf32;
while (sbuf32 < send32)
*dbuf8++ = xfrm_pixel(le32_to_cpup(sbuf32++));
}