Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp875725rwi; Wed, 19 Oct 2022 04:11:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5OapKPP4XZrVXc0sMEzsIdRyyy6aLW8xxyTuEXSgGfNulEzMLzHV0f0Sb5qtnx3Sgb3rrT X-Received: by 2002:a17:90b:3505:b0:20d:ba2e:994b with SMTP id ls5-20020a17090b350500b0020dba2e994bmr32862147pjb.46.1666177787938; Wed, 19 Oct 2022 04:09:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666177787; cv=none; d=google.com; s=arc-20160816; b=uB0xbnTgwqVpTx/CW23mR6rZBwZWskrlC6x/0HpP3uzYtMxyy1KUj1kDaeBXhA2X0a IlkzIo2OfxgZocshBamk9modmFHAlaHuQqyIWzl3qRB60MzgtqWvEhDbr+uwe1CI4ZCL 5VTvX9zEWTNHQBAxjOi29FSeusZn/E11exKWdYD4g12oM7TDyy3EHhF6ElKunhLCpWTm H7G2wZTQF1doImqxKMf7JBnxp+yiZrwKUDhYKR18siDiOy6rzfCwJP9Ufd3HWRh1qyY8 dajpX+f1Xrq4IyW6jS5+LS4nR25IfilOgEVVkzbsveCkj5QB/JnPti9yjWTirJ4yrYZ0 oN8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VHGesMtAzo8FPiBH/wj1OVOaaJOl88BTUokQhG+Xhiw=; b=MJaqw9DF526fFbCDwzu4gM5tGWh7JOysvb3PybO6BKivETC5kA5xO6DP8pBz05hwtH SpcCN0YyZAncvRsLLNgi3h8I7rjWnrWN37TGNpGEc+bCaqhiSt1b6CkVMC2QgHsJgpmO zNI6XdqDnYpgXlSPAdXyfHrDgl94wTFWQ+Leo9gkOGNn9yEMXAJDB0/wsdcehxQIALsS 9Um/kvvzJGU61IHioMl3pdIQgUHfjgkKnkvye8BUb10yfImI/URkUKmT5qUqv0xmH5wI zeMxm3U+svz02TRqNOFRXdh85VSLOYV7kVaRuD1qB+Ys+kDB97RaDFxSyDhKl9/irKIv qP9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lil9xeFs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j4-20020a170902da8400b0017f6557bf88si21735014plx.588.2022.10.19.04.09.34; Wed, 19 Oct 2022 04:09:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lil9xeFs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232710AbiJSKpj (ORCPT + 99 others); Wed, 19 Oct 2022 06:45:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232761AbiJSKoF (ORCPT ); Wed, 19 Oct 2022 06:44:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A3C3AB803; Wed, 19 Oct 2022 03:20:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2A72FB823BA; Wed, 19 Oct 2022 08:54:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B77DC433D6; Wed, 19 Oct 2022 08:54:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169650; bh=esWIenx8gII1JJLWa5PV7a3Z/OUnhFQz9LcMdo2nw8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lil9xeFsifLllLfompE4Ew2KE3jViYbjMlpACsCfiXx3+6/kVOzbRaNKaUjih9g79 P5GYAhBfGYfLkSSp2Pt9Uu/qcLe+JIxQf/7usHA4ZiBsbmE5UMbD4KIHHScZxjmTzo PzX6TusEqonMSZpXDCxlPVULzredzjHX4vzXwk9U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Gow , =?UTF-8?q?Jos=C3=A9=20Exp=C3=B3sito?= , Sasha Levin Subject: [PATCH 6.0 357/862] drm/format-helper: Fix test on big endian architectures Date: Wed, 19 Oct 2022 10:27:24 +0200 Message-Id: <20221019083305.790911380@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: José Expósito [ Upstream commit 18c8485236a5e3f491b670c018ae391c9cb84dfa ] The tests fail on big endian architectures, like PowerPC: $ ./tools/testing/kunit/kunit.py run \ --kunitconfig=drivers/gpu/drm/tests \ --arch=powerpc --cross_compile=powerpc64-linux-gnu- Transform the XRGB8888 buffer from little endian to the CPU endian before calling the conversion function to avoid this error. Fixes: 8f456104915f ("drm/format-helper: Add KUnit tests for drm_fb_xrgb8888_to_rgb332()") Reported-by: David Gow Reviewed-by: David Gow Signed-off-by: José Expósito Link: https://patchwork.freedesktop.org/patch/msgid/20220726230916.390575-2-jose.exposito89@gmail.com Signed-off-by: Sasha Levin --- .../gpu/drm/tests/drm_format_helper_test.c | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/tests/drm_format_helper_test.c b/drivers/gpu/drm/tests/drm_format_helper_test.c index 98583bf56044..eefaba3aaea2 100644 --- a/drivers/gpu/drm/tests/drm_format_helper_test.c +++ b/drivers/gpu/drm/tests/drm_format_helper_test.c @@ -111,6 +111,21 @@ static size_t conversion_buf_size(u32 dst_format, unsigned int dst_pitch, return dst_pitch * drm_rect_height(clip); } +static u32 *le32buf_to_cpu(struct kunit *test, const u32 *buf, size_t buf_size) +{ + u32 *dst = NULL; + int n; + + dst = kunit_kzalloc(test, sizeof(*dst) * buf_size, GFP_KERNEL); + if (!dst) + return NULL; + + for (n = 0; n < buf_size; n++) + dst[n] = le32_to_cpu((__force __le32)buf[n]); + + return dst; +} + static void xrgb8888_to_rgb332_case_desc(struct xrgb8888_to_rgb332_case *t, char *desc) { @@ -125,6 +140,7 @@ static void xrgb8888_to_rgb332_test(struct kunit *test) const struct xrgb8888_to_rgb332_case *params = test->param_value; size_t dst_size; __u8 *dst = NULL; + __u32 *src = NULL; struct drm_framebuffer fb = { .format = drm_format_info(DRM_FORMAT_XRGB8888), @@ -138,8 +154,11 @@ static void xrgb8888_to_rgb332_test(struct kunit *test) dst = kunit_kzalloc(test, dst_size, GFP_KERNEL); KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dst); - drm_fb_xrgb8888_to_rgb332(dst, params->dst_pitch, params->xrgb8888, - &fb, ¶ms->clip); + src = le32buf_to_cpu(test, params->xrgb8888, TEST_BUF_SIZE); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, src); + + drm_fb_xrgb8888_to_rgb332(dst, params->dst_pitch, src, &fb, + ¶ms->clip); KUNIT_EXPECT_EQ(test, memcmp(dst, params->expected, dst_size), 0); } -- 2.35.1