From patchwork Thu Nov 16 13:10:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 165799 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp3200589vqg; Thu, 16 Nov 2023 05:14:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUBbngUiyZNfl7KLgSrZenR+LC2CIq3YYDcUYvjVTxqPFn86bPSvKLLCDXFawBs6GrtGFZ X-Received: by 2002:a05:6830:2695:b0:6d6:4e53:c81b with SMTP id l21-20020a056830269500b006d64e53c81bmr10246220otu.8.1700140450954; Thu, 16 Nov 2023 05:14:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700140450; cv=none; d=google.com; s=arc-20160816; b=W6JIgiRoyaTpsQ5SWEpLm4qiG/R9IwugTPGfGn4n5SNq/VRzVpuiV1RYysPivMUrOs Yh0abqCcwGef1hPD5DtvWDVTleO0f0+++mUgHQWW8pkrHzp2QlIOuGpa/cpbcBhDby8y WQYKChgUXexOsuTsSiGIIdKEglDyiCxLBvuWorvprmESXNR90PVBoCqnzODl8KeqpviD MGxuJYoWGh+Fa8CTQnWdVVkzYVD2Yv3NusDzskQOmqph1us6NyqAT4UBgQbvIBmkPgSo N4sbQM/K2DJjnSvTcraarmypBuI7lAfg051BKEK436oav6YWUeyeWfAm0NdldMqqF5Z4 XLSg== 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 :message-id:date:subject:cc:to:from; bh=OWs7oYcS6h8XWclrBiR7QnT/w2wSTYjI3ge/5w4bhA8=; fh=zLstxgNMMh1B6h8MhYLJ9DtRg0Iqm+iFBlJBHyeyoAY=; b=eW2BBWmPpwLWRSBm2gk/vgYPIq/9MNn+A+GFeldpICgwL1jFWlgu+dpSp1wLqBrBfM bh40WOW/poRjonihDKpXOET8jQQnevp23YQh6cH36KUtj93HjJpYRrolLzQhUrPWIrEU liQCO3TnNh9fsDvmfp3fs4fVAfMFIhqyh15Kln+IbnIBsdbmUt6g+mradRBwcrmLjfmH nMm6MXoXTnkVsQZGSUCC9QGnTptUG3Q97iL9jSXBhENCWPfKkopNEz8Cfhppz3SQbDga ev3aZ+O81RucYjzXOyhhMUcw7xCyBeU893ufwiA6Hvkk8HN0b6csJQ5S6CeBDv+Clu8V tSfQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id a34-20020a634d22000000b005afc5ea43fdsi11787910pgb.849.2023.11.16.05.14.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Nov 2023 05:14:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 4313D80FF2A5; Thu, 16 Nov 2023 05:14:08 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231152AbjKPNNz (ORCPT + 29 others); Thu, 16 Nov 2023 08:13:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345210AbjKPNNq (ORCPT ); Thu, 16 Nov 2023 08:13:46 -0500 Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FFDFD6C for ; Thu, 16 Nov 2023 05:13:39 -0800 (PST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed40:1f07:ca72:c5f4:4244]) by albert.telenet-ops.be with bizsmtp id B1DW2B00N4CbZ7h061DWyA; Thu, 16 Nov 2023 14:13:36 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1r3cBI-009QEp-HK; Thu, 16 Nov 2023 14:13:27 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1r3c8e-007XJZ-UG; Thu, 16 Nov 2023 14:10:32 +0100 From: Geert Uytterhoeven To: Christian Zigotzky , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Daniel Vetter , Thomas Zimmermann , Laurent Vivier , Javier Martinez Canillas , Hamza Mahfooz , linux-m68k@lists.linux-m68k.org Cc: dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] drm/virtio: Add suppport for non-native Date: Thu, 16 Nov 2023 14:10:30 +0100 Message-Id: <282a31154172a78165912c832a09f6502515d139.1700140178.git.geert@linux-m68k.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 16 Nov 2023 05:14:08 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782726473361719332 X-GMAIL-MSGID: 1782726473361719332 When using virtgpu on a big-endian machine, e.g. powerpc QEMU: virtio-pci 0000:00:02.0: [drm] *ERROR* fbdev: Failed to setup generic emulation (ret=-2) or m68k/virt: virtio-mmio virtio-mmio.125: [drm] *ERROR* fbdev: Failed to setup generic emulation (ret=-2) and the graphical display fails to come up. Before, the call to drm_mode_addfb() caused a translation from a fourcc format (XR24) to a bpp/depth pair (32/24) to a potentially different fourcc format (BX24 on big-endian), due to the quirk processing in drm_driver_legacy_fb_format(). After, the original fourcc format (XR24) is passed unmodified. However, the virtgpu DRM driver supports only a single format for its main plane: DRM_FORMAT_HOST_XRGB8888, which is XR24 on little-endian, and BX24 on big-endian. I.e. on big-endian, virtgpu does not support XR24, which is the default DRM format, and must be supported by all drivers. Before, this was reported, but didn't lead to a failure: virtio-mmio virtio-mmio.125: [drm] bpp/depth value of 32/24 not supported virtio-mmio virtio-mmio.125: [drm] No compatible format found As the core virtgpu driver and device support both XR24 and BX24 on both little-endian and big-endian just fine, fix this extending the list of supported formats for main plane and cursor plane to XR24/BX24 resp. AR24/BA24. Fixes: 6ae2ff23aa43a0c4 ("drm/client: Convert drm_client_buffer_addfb() to drm_mode_addfb2()") Reported-by: Christian Zigotzky Closes: https://lore.kernel.org/r/c47fba21-3ae9-4021-9f4a-09c2670ebdbc@xenosoft.de Suggested-by: Gerd Hoffmann Signed-off-by: Geert Uytterhoeven Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/virtio/virtgpu_display.c | 11 +++++++++-- drivers/gpu/drm/virtio/virtgpu_plane.c | 6 ++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_display.c b/drivers/gpu/drm/virtio/virtgpu_display.c index ad924a8502e9025c..49c89000aec33f23 100644 --- a/drivers/gpu/drm/virtio/virtgpu_display.c +++ b/drivers/gpu/drm/virtio/virtgpu_display.c @@ -301,9 +301,16 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev, struct virtio_gpu_framebuffer *virtio_gpu_fb; int ret; - if (mode_cmd->pixel_format != DRM_FORMAT_HOST_XRGB8888 && - mode_cmd->pixel_format != DRM_FORMAT_HOST_ARGB8888) + switch (mode_cmd->pixel_format) { + case DRM_FORMAT_XRGB8888: + case DRM_FORMAT_ARGB8888: + case DRM_FORMAT_BGRX8888: + case DRM_FORMAT_BGRA8888: + break; + + default: return ERR_PTR(-ENOENT); + } /* lookup object associated with res handle */ obj = drm_gem_object_lookup(file_priv, mode_cmd->handles[0]); diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c b/drivers/gpu/drm/virtio/virtgpu_plane.c index a2e045f3a0004a1b..a547d76b8fb0a77d 100644 --- a/drivers/gpu/drm/virtio/virtgpu_plane.c +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c @@ -30,11 +30,13 @@ #include "virtgpu_drv.h" static const uint32_t virtio_gpu_formats[] = { - DRM_FORMAT_HOST_XRGB8888, + DRM_FORMAT_XRGB8888, + DRM_FORMAT_BGRX8888, }; static const uint32_t virtio_gpu_cursor_formats[] = { - DRM_FORMAT_HOST_ARGB8888, + DRM_FORMAT_ARGB8888, + DRM_FORMAT_BGRA8888, }; uint32_t virtio_gpu_translate_format(uint32_t drm_fourcc)