From nobody Sun Feb 8 21:55:47 2026 Received: from exactco.de (exactco.de [176.9.10.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64E8730BB8C for ; Fri, 12 Dec 2025 20:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=176.9.10.151 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765569903; cv=none; b=sLvHSpGz1J2WlfuAXsdE3nBeweWGeA/tn6jeYbVRCWHsD2nRlPuHVVit5yFuMirEF0aeGcVuhbzF3CC9Mor/5jCKic+9RR2g+nhBl3Tgt7iPZBzNPw3s+Hbw7URh2XI0ekxYSGAR+AN+qogkiL9EOkHS0UUjUaeSaiiV9QO4Xe4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765569903; c=relaxed/simple; bh=u5L4Pp/3lcvQw/XfrzwRR1ban//ki8w2sO81lZkE9+Q=; h=Date:Message-Id:To:Cc:Subject:From:Mime-Version:Content-Type; b=o54AaAsAHQF37wc54Ei4xed/bM4KI/h/TnQBKUA+TlElA+X5htGGhYaEXphtjobUHXsgFyN+xVu6Ki3EBw0M3Ge2whcVY+jnBzDrLs9SWeDbhSDN9uqdGA0D6ctlUTCVaYkvFsKaps84aTjPV0RY6ysWOESgtzLpvfaGtrYPipY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=exactco.de; spf=pass smtp.mailfrom=exactco.de; dkim=pass (2048-bit key) header.d=exactco.de header.i=@exactco.de header.b=F6abWy6Z; arc=none smtp.client-ip=176.9.10.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=exactco.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=exactco.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=exactco.de header.i=@exactco.de header.b="F6abWy6Z" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=exactco.de; s=x; h=Content-Transfer-Encoding:Content-Type:Mime-Version:From:Subject:Cc:To :Message-Id:Date:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=1ajfBSYTJP67RDhKYmipkvA8f5Djql9PgZl5Sg4qV+8=; b=F 6abWy6ZVyOcnC9CwB3pi903LQkX1CK8OOB6iH7SdmWWGJBJGj1KXXCia3L+jLm3r8mo+YbOkbG6X1 APvTlIfdEfCGQ920QjaaHlJTAUddgM5FoADAeTyhWPs9ufW3BjPu+ME3lP3pZuL5076mdQCt8/LeP o5GUHa/vhyLkevub0VQvpHSZHiQUCdCxIQrFkx9dqZ6d4cyIErKfviFE1Fkc5kyROdyMrrS0UkmZg ca/x+6DuWUVECT8ZhTbvTF/i4475ciobscnx8rOslfrXxiB8N4b1TsAI2QyRrnYb6Y03FrpZZGTPu 9sjJv6+VHUiE1DgCyV3/2ZW5xePyl0G3w==; Date: Fri, 12 Dec 2025 21:05:04 +0100 (CET) Message-Id: <20251212.210504.1355099120650239629.rene@exactco.de> To: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Dave Airlie , Thomas Zimmermann Subject: [PATCH V4] drm/ast: Swap framebuffer writes on big-endian machines From: =?iso-8859-1?Q?Ren=E9?= Rebe X-Mailer: Mew version 6.10 on Emacs 30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: Text/Plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Swap the pixel data when writing to framebuffer memory on big-endian machines. Fixes incorrect output. Aspeed graphics does not appear to support big-endian framebuffers after AST2400, although the feature has been documented. There's a lengthy discussion at [1]. Signed-off-by: Ren=C3=A9 Rebe Link: https://lore.kernel.org/dri-devel/20251202.170626.2134482663677806825= .rene@exactco.de/ # [1] Reviewed-by: Thomas Zimmermann --- The ARGB4444 cursor not yet 100% correct, but that might be another layer/h= elper bug. Tested on sparc64 T4-1 running T2/Linux. --- drivers/gpu/drm/ast/ast_cursor.c | 11 ++++++++--- drivers/gpu/drm/ast/ast_mode.c | 11 +++++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/ast/ast_cursor.c b/drivers/gpu/drm/ast/ast_cur= sor.c index 2d3ad7610c2e..d4620171d845 100644 --- a/drivers/gpu/drm/ast/ast_cursor.c +++ b/drivers/gpu/drm/ast/ast_cursor.c @@ -92,12 +92,17 @@ static void ast_set_cursor_image(struct ast_device *ast= , const u8 *src, unsigned int width, unsigned int height) { u8 __iomem *dst =3D ast_plane_vaddr(&ast->cursor_plane.base); - u32 csum; - - csum =3D ast_cursor_calculate_checksum(src, width, height); + u32 csum =3D ast_cursor_calculate_checksum(src, width, height); =20 /* write pixel data */ +#if defined(__BIG_ENDIAN) + unsigned int i; + + for (i =3D 0; i < AST_HWC_SIZE; i +=3D 2) + writew(swab16(*(const __be16 *)&src[i]), &dst[i]); +#else memcpy_toio(dst, src, AST_HWC_SIZE); +#endif =20 /* write checksum + signature */ dst +=3D AST_HWC_SIZE; diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index cd08990a10f9..57c6fbc3232b 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c @@ -526,12 +526,18 @@ static int ast_primary_plane_helper_atomic_check(stru= ct drm_plane *plane, =20 static void ast_handle_damage(struct ast_plane *ast_plane, struct iosys_ma= p *src, struct drm_framebuffer *fb, - const struct drm_rect *clip) + const struct drm_rect *clip, + struct drm_format_conv_state *fmtcnv_state) { struct iosys_map dst =3D IOSYS_MAP_INIT_VADDR_IOMEM(ast_plane_vaddr(ast_p= lane)); =20 iosys_map_incr(&dst, drm_fb_clip_offset(fb->pitches[0], fb->format, clip)= ); + +#if defined(__BIG_ENDIAN) + drm_fb_swab(&dst, fb->pitches, src, fb, clip, !src[0].is_iomem, fmtcnv_st= ate); +#else drm_fb_memcpy(&dst, fb->pitches, src, fb, clip); +#endif } =20 static void ast_primary_plane_helper_atomic_update(struct drm_plane *plane, @@ -561,7 +567,8 @@ static void ast_primary_plane_helper_atomic_update(stru= ct drm_plane *plane, if (drm_gem_fb_begin_cpu_access(fb, DMA_FROM_DEVICE) =3D=3D 0) { drm_atomic_helper_damage_iter_init(&iter, old_plane_state, plane_state); drm_atomic_for_each_plane_damage(&iter, &damage) { - ast_handle_damage(ast_plane, shadow_plane_state->data, fb, &damage); + ast_handle_damage(ast_plane, shadow_plane_state->data, fb, &damage, + &shadow_plane_state->fmtcnv_state); } =20 drm_gem_fb_end_cpu_access(fb, DMA_FROM_DEVICE); --=20 2.52.0 --=20 Ren=C3=A9 Rebe, ExactCODE GmbH, Berlin, Germany https://exactco.de =E2=80=A2 https://t2linux.com =E2=80=A2 https://patreon.= com/renerebe