Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1816233imm; Mon, 3 Sep 2018 10:09:59 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZ62ZS55mdImHPn7kLR32r0Pxl3sv+fwWcmqafJwtzIN/jjTtU5WRnghrdbfnpkM84XaVi0 X-Received: by 2002:a63:804a:: with SMTP id j71-v6mr25334917pgd.171.1535994599435; Mon, 03 Sep 2018 10:09:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535994599; cv=none; d=google.com; s=arc-20160816; b=f/KIhfmMKFpAOU1bB5cFLMClJe3mIESSpLAcrYHV3KPEOJ68w94qIbkICtDoQ7K9Aq hHiwhdJ5iML89GRgbBGoSjvp0z+SFMPbiKTPqklPAaNSE7R4PjH/uuA38vl/EOrYmURF KNjDz6awUcUCXeGglSjrH1qmMg9eBIfXehcY5oWxw9k1TVPE6SpQLB1F8NVN2DaeQSXH nOsmIYNPsLXTG/CWVrtV8onR9mFU3X5EHLJTrZdXJOU6KVGhUeN6tcnStvcd2gB1/MP6 VAl1TIl5lI1U26CS6n6Cz/vpp9SAc0DxTDpPZ49cHfIWqHvt2vIdHLOICJ+x6SIUsvdy FoyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=55EDEKAgSLIisF9zDcpy4XHNQuoyOjZtklhxy7zTx60=; b=vbHztTn3tq9ZwGSRHmk2PZGVBtB91PT2qsnyI4dNcQLBKzBhLjSF76cUoi2Y+c3Ibx X1cNnWJOjYhLptWXiclfhTEvENPgpjh8aM4QMucwb0xsyjiqJNLDN6ctlCJeuF5Qiq1J l7foFveoUq2RhMuAKysKK5woVIcu4emJD6glNnw+5qTL0+Xn7HFt4ftkVjovRJCo8uXp MzBGxgn8l3C2rPe47K1bnGURgCtmJftSTqY+XPmlt74PMLlV/YLIdsOdZhJ62sB/kNZv YncaG5lY2LIR4NERYEQVd94uodSHjYxmi0gIZnP2OzdPCC3CWh7YUxkRRbXcn7F7ctKa z3WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=autOzqPj; 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 d2-v6si17039556pfg.87.2018.09.03.10.09.44; Mon, 03 Sep 2018 10:09:59 -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=autOzqPj; 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 S1729613AbeICV2y (ORCPT + 99 others); Mon, 3 Sep 2018 17:28:54 -0400 Received: from mail-ua1-f67.google.com ([209.85.222.67]:43125 "EHLO mail-ua1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729392AbeICV2y (ORCPT ); Mon, 3 Sep 2018 17:28:54 -0400 Received: by mail-ua1-f67.google.com with SMTP id f4-v6so871724uao.10 for ; Mon, 03 Sep 2018 10:07:53 -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; bh=55EDEKAgSLIisF9zDcpy4XHNQuoyOjZtklhxy7zTx60=; b=autOzqPjxGjSGSEUvcjc/AKWnfycKLPalbHzqjqyanWkSdzDi6RzL4PSuAjP0AVNOF VZsb3s32jBBlJU73xqdwNlOm0suHl6Z3TCN1LCVoksrAuNYpDyyuk2iArkD525CB+zY9 4Qfkgd5Wn5ByfjG1tsUXu1o3e6gXLdp2hUj7A+x7c7Ci08/JkUOe2nQCWVSPy4esXdXo PGKhcStUjjuUegziVMHCwitC1FXaM3Z5lCMWXPJSb2i0psVWroLB3FTs4j5uctDkcZj7 qc6di2MGGJn9TwKJABMNmAfC0rnW7jUiptxvv4uQJHB9V6pG+zip3pAmJFBu+eL2DLe7 vDkw== 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; bh=55EDEKAgSLIisF9zDcpy4XHNQuoyOjZtklhxy7zTx60=; b=ro3CJFYidXc1jwDNdl5FI85IKi5tJSB61qEqRmgDTOsmNcbPBl1zlHn8SazqARVgrr HjYvTdxgaLpOSski0wW0pytOV7oiUCVUSuCBCmVIdbgKv3NfLGlOvVg2AmEWNnbH4eS4 wbu0AGZVksdVu0zkb2Faasdfmvhg5QvdfV0vMnYTvFLvjNzZyxFoNkZ7MWFQol5ReYoM 0P0OjkBYD+siDKNkdJSSxRI5bbwLwj+IpXnzTASmc8T2S1rbLtdD6MEJ+YP1AQvyHxJ6 /8H99Of8vTyRfve/iqmzTa2fcCuAPiToCq+kg+K5ojmZnX/P7oE9NJRUnA41q01zfBDx w3Rw== X-Gm-Message-State: APzg51BXV79wuunu50PnqFnHtljr5ocurXrDE7RiY4Iwj8LtQV3HDfXo 6rcnWnkWpSAxjC5r59b+xq+AmtJtj1fwy4tbFwk= X-Received: by 2002:a9f:3c46:: with SMTP id w6-v6mr16431671uah.185.1535994472817; Mon, 03 Sep 2018 10:07:52 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ab0:26ca:0:0:0:0:0 with HTTP; Mon, 3 Sep 2018 10:07:52 -0700 (PDT) In-Reply-To: <20180903164558.GL21634@phenom.ffwll.local> References: <20180903105756.24912-1-kraxel@redhat.com> <20180903105756.24912-4-kraxel@redhat.com> <20180903164558.GL21634@phenom.ffwll.local> From: Ilia Mirkin Date: Mon, 3 Sep 2018 13:07:52 -0400 X-Google-Sender-Auth: ogv0M08Mtx0sM1G8YDrJIKgPSSc Message-ID: Subject: Re: [PATCH 3/5] drm: fix drm_mode_addfb() on big endian machines. To: Gerd Hoffmann , dri-devel , David Airlie , open list , Sean Paul Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 change >> drm_mode_addfb() behavior for everybody without breaking things. So add >> a new driver feature flag DRIVER_PREFER_HOST_BYTE_ORDER, so drivers can >> 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 think > 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 upside > 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 only > 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, and then made to be the one-and-only way for ADDFB to function. That way we'll no longer be lying about the DRM_FORMAT being used. Cheers, -ilia