Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2529272imm; Tue, 4 Sep 2018 06:07:08 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZTkHTi6B0PSrKU0Z+wY4ojAsWs2mbxxUdqBLWFVT9dXuNTgi6rHSBzRrNyI9wmHjAaWa95 X-Received: by 2002:a63:f751:: with SMTP id f17-v6mr31169793pgk.410.1536066428288; Tue, 04 Sep 2018 06:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536066428; cv=none; d=google.com; s=arc-20160816; b=vLKGo9Lgg0R/MMw6RFA9gJsIMYqRO7ihZ/6TxPcrhfyIhZUrW3FMB3rPe4g4sbM1Ga ym+QBvJzW8nSqs32XMDPX7v/VCkPVIDq1xIAX9/BOkRzHFhBpwX1GDCF1Rudry4YLvNp jtmTp5nzIObvmZIr79cefuAq9SzEqUqiotcm02Yo+p0MMxjabxt0yZ75Rhbcqei5jOGW UnqeClYK5hMjOOvN8TykOdRRUGf9lXOR8cc27W5epmu40GL/ebEfqWlTKm1M0lpf1XQ8 3npoBoqxE83fYTjdNmQb/kPeS30GtYtePruLNR5eZ4YNGXujv/xd0yOnLP1xJVemn6to T7lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=xMBlk1xhJfYmzpnhc9zhpbrRbwfMC3Ul99na0u209Zw=; b=Sko5IvWUeVGSIQWDo7nUF5VjkRSDCmwOgVtceUYl3Rhmwhh7umiyzoE1AWeW8TUdH9 vKgP9fKot5YhMjnKUx1pnT45E8YFasN8OC6YqGMWnl5w0St4qlsXYQmzspLgy9b1N3sN /sHCB+GHpN9P4tKKGuisXBRKQfiFbo8f/Jm0bYM+t/Jh4qY2+brl6VXPZBWCbx53+iyY AChw3wXFxw3q0M7QLocJiP6vT1B7HDzqYq0yKb2NBDM6sYtgWOVyoL9eMQDUkChnQcbU TM+Zo4jvl/KEXUhEOGuGldQ6fr//Uh0gUt4G8GRnc26gexii6ppMN2fTGuIsuVkaQ1ID oTig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=OblZKcqT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k15-v6si21198242pgi.62.2018.09.04.06.06.53; Tue, 04 Sep 2018 06:07:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=OblZKcqT; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727447AbeIDRaO (ORCPT + 99 others); Tue, 4 Sep 2018 13:30:14 -0400 Received: from mail-ua1-f67.google.com ([209.85.222.67]:34411 "EHLO mail-ua1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726355AbeIDRaO (ORCPT ); Tue, 4 Sep 2018 13:30:14 -0400 Received: by mail-ua1-f67.google.com with SMTP id r15-v6so2795215uao.1 for ; Tue, 04 Sep 2018 06:05:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=xMBlk1xhJfYmzpnhc9zhpbrRbwfMC3Ul99na0u209Zw=; b=OblZKcqTn1FxY7oTtJEOqxFyBe78DFeP5vXcQNdajNByizu16uTjRREXTL5hopgbW8 us36HF1zFzZ3RibQlSfRnBARVjFkLyoqEd3BlF8Y2ftkfr020Y+hXB9UzWpSkc/8leJE TSFKw4Gc8Ga6geXLwr3QaLuJn27Gz/tC/gEhJUCS3L6KyLlT238sXxuAYAqLvOeU/cLA dwtd7AgEVsvK+Yazy2gL+QRNo3cfBjAD+iPe3BNkVE67ivvHwnY63PSPJaj4izsoxZwE 2An1TARBCuSndCjsODU5IBx3D0YSvdCFoNc0gJc1pCbdE9q2GH2c82h8bZRseaPsrYd3 QCvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc:content-transfer-encoding; bh=xMBlk1xhJfYmzpnhc9zhpbrRbwfMC3Ul99na0u209Zw=; b=FXkKUKfpig9O/2BtrxIJ48GXAtCiu5/rLp69q4WSS5yPXR2Mvto5u+Hsvb2CFb3rGb LdgFJsqaCYT7L4fUGTgBl7hO3GQEaGlv8LHTFWVEFVrYAZWoxWrxEwPwXhkLP3/LquSi zVFbdheKDMVt+3sFnN3jCM/r4zEhDdwWLihyz0dgPlheUm2LeQ9ZI7Sq+EJiChHPHO6j 67u2i7N5cIcvVjhzVPsMznGE6ZLgyv8S8s9WIj/6SxdaC0Zly38kaOe/xaHQ9ov97m2D BzMl1FZ0e02YzOQfyqRptgNHdBtrhU802EYpiQ5vpzE+KvDswkuN0vByH7L9xFHrsq9h I8EQ== X-Gm-Message-State: APzg51Bju4OP03ky+1RrGJyWBvS39UvJGkAb7ff4ApuHWCwI+vNtnlWg k9uMSXTd/3bcQANqtuQBCci41DuM5OzoAk7EA2I= X-Received: by 2002:ab0:72ca:: with SMTP id g10-v6mr17936058uap.33.1536066310077; Tue, 04 Sep 2018 06:05:10 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:26ca:0:0:0:0:0 with HTTP; Tue, 4 Sep 2018 06:05:09 -0700 (PDT) In-Reply-To: <8e8f8cf3-c4d4-6bfd-4e53-536d4d0c79ff@daenzer.net> References: <20180903105756.24912-1-kraxel@redhat.com> <20180903105756.24912-4-kraxel@redhat.com> <20180903164558.GL21634@phenom.ffwll.local> <8e8f8cf3-c4d4-6bfd-4e53-536d4d0c79ff@daenzer.net> From: Ilia Mirkin Date: Tue, 4 Sep 2018 09:05:09 -0400 X-Google-Sender-Auth: sbGG1ZK3auqlEu5x_2-VQG2gqNA Message-ID: Subject: Re: [PATCH 3/5] drm: fix drm_mode_addfb() on big endian machines. To: =?UTF-8?Q?Michel_D=C3=A4nzer?= Cc: Gerd Hoffmann , David Airlie , Sean Paul , dri-devel , open list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Sep 4, 2018 at 4:00 AM, Michel D=C3=A4nzer wro= te: > On 2018-09-03 7:07 p.m., Ilia Mirkin wrote: >> On Mon, Sep 3, 2018 at 12:45 PM, Daniel Vetter wrote: >>> On Mon, Sep 03, 2018 at 12:57:54PM +0200, Gerd Hoffmann wrote: >>>> Userspace on big endian machhines typically expects the ADDFB ioctl >>>> returns a big endian framebuffer. drm_mode_addfb() will call >>>> drm_mode_addfb2() unconditionally with little endian DRM_FORMAT_* >>>> values though, which is wrong. This patch fixes that. >>>> >>>> Drivers (both kernel and xorg) have quirks in place to deal with the >>>> broken drm_mode_addfb() behavior. Because of this we can't just chang= e >>>> drm_mode_addfb() behavior for everybody without breaking things. So a= dd >>>> a new driver feature flag DRIVER_PREFER_HOST_BYTE_ORDER, so drivers ca= n >>>> opt-in. >>>> >>>> Signed-off-by: Gerd Hoffmann >>>> --- >>>> include/drm/drm_drv.h | 1 + >>>> drivers/gpu/drm/drm_framebuffer.c | 11 +++++++++++ >>>> 2 files changed, 12 insertions(+) >>>> >>>> diff --git a/include/drm/drm_drv.h b/include/drm/drm_drv.h >>>> index 46a8009784..9cf12596cd 100644 >>>> --- a/include/drm/drm_drv.h >>>> +++ b/include/drm/drm_drv.h >>>> @@ -57,6 +57,7 @@ struct drm_printer; >>>> #define DRIVER_KMS_LEGACY_CONTEXT 0x20000 >>>> #define DRIVER_SYNCOBJ 0x40000 >>>> #define DRIVER_PREFER_XBGR_30BPP 0x80000 >>>> +#define DRIVER_PREFER_HOST_BYTE_ORDER 0x100000 >>> >>> Hm, not a huge fan of using driver_flags for random little quirks. I th= ink >>> a boolean in sturct drm_mode_config would be much better. Bonus if you >>> also move the 30bpp hack over to that. Something like >>> mode_config.quirk_addfb_host_byte_order and >>> mode_config.quirk_addfb_prefer_xbgr_30bpp or whatever. That has the ups= ide >>> of giving us a really nice place to put a huge comment about what this = is >>> supposed to do. >>> >>> I think otherwise this looks overall rather reasonable. I think the onl= y >>> other driver that ever cared about big endian was radeon/amdgpu. Would = be >>> good to get at least an ack from amd folks, or a "meh, stopped caring". >> >> and nouveau. >> >> I do believe that ADDFB should be made to always prefer host byte >> order -- this is how all of the existing implementations work in >> practice. However e.g. nouveau wants DRM_FORMAT_XRGB8888. But it still >> treats it as host byte order. This will become more important in a >> world where ADDFB2 is more common. >> >> So, I think that this change should be applied, drivers (I suspect >> just nouveau and radeon) fixed up to consume the "new" formats, [...] > > As explained before, that would break radeon userspace on big endian host= s. We last discussed this about a year ago, so I hope you'll forgive my lapse in memory... There's userspace that uses ADDFB2 with DRM_FORMAT_XRGB8888 but expects it to be host-endian? If so, that'll be a problem for nouveau as well... -ilia