Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2661359imm; Tue, 4 Sep 2018 08:04:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYoHNeSJQ6PHz8fk0A5uM49XAPYt4XrVaVo8rBy1siqze9TBzprcXjxlMSeeP5wIOiY/S44 X-Received: by 2002:a81:9106:: with SMTP id i6-v6mr18866830ywg.371.1536073473443; Tue, 04 Sep 2018 08:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536073473; cv=none; d=google.com; s=arc-20160816; b=Z85XhbW/mux2DcOPXfcef3EMsPQRalJOeGUtUGtUDEifmv4uvToQnnLL54JknHz8t5 NInNUZEq6zAxBTcrTcZPJ40kszf9vosnM3ntdc4BrnJBPXdnCeLpltVXDbAVLadp3nqQ eg1sESSiwFUPDPDGA6n2AO2RXfXZ/ciOCwMjPznQNwL0JfdKvtJuI2ZuFUpk4xt9LY4E A5tpb0+6UqyAcsMzbvBdoE3y0KElBmgowK0IQHZOc4t4CXcSD6O+YEoVNqpx3SKJv1r8 t2zJNALl18TqAmgg6/wOkMR3xP436v9eLFA8KQbRMkcQxEAUW4PDr1e5q/Ifc6SLOCAz UdAA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :arc-authentication-results; bh=y7q2M1DefdRG42VUlCWm05NNaQTG78oAQD1BY/NQCF0=; b=bWBaRvJsGFXPVGIbzUk7POjSic+2TmHYdG4uGCmDxDR+ZYAxT+C4+GnqMRZjao0IXZ bkF7jFc9DkyoQybYrv7SHi4RybuwYES+JEmWrnJpOuinE2N3NGFTwxvoeom9c18TTOh/ aDTpe+eG9foNPC78ePPRg7ZIZhJ/Lbw4iFKbOBDKIMyfYlkjVsmoQCgMNaGTsbZDbWVl VRmCSzrRwbOLVo7BcOGKA32oAfYqTls1uChvhlsHxUE52SgjnL/AvytSImJlSK8iiEPY H1JQC7qQxaUXbERymBPbTZW/wUrne5pSWc2i19XUeS27mym+kwr62/ochULmN9Z1Vw21 qdDg== ARC-Authentication-Results: i=1; mx.google.com; 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 l1-v6si21587592pgo.377.2018.09.04.08.04.17; Tue, 04 Sep 2018 08:04:33 -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; 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 S1727278AbeIDT1q (ORCPT + 99 others); Tue, 4 Sep 2018 15:27:46 -0400 Received: from mail.netline.ch ([148.251.143.178]:39716 "EHLO netline-mail3.netline.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726015AbeIDT1q (ORCPT ); Tue, 4 Sep 2018 15:27:46 -0400 Received: from localhost (localhost [127.0.0.1]) by netline-mail3.netline.ch (Postfix) with ESMTP id BF45E2A6049; Tue, 4 Sep 2018 17:02:14 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at netline-mail3.netline.ch Received: from netline-mail3.netline.ch ([127.0.0.1]) by localhost (netline-mail3.netline.ch [127.0.0.1]) (amavisd-new, port 10024) with LMTP id UjSA1bCL47W9; Tue, 4 Sep 2018 17:02:13 +0200 (CEST) Received: from thor (67.124.127.176.dynamic.wline.res.cust.swisscom.ch [176.127.124.67]) by netline-mail3.netline.ch (Postfix) with ESMTPSA id 3B9D82A6042; Tue, 4 Sep 2018 17:02:13 +0200 (CEST) Received: from localhost ([::1]) by thor with esmtp (Exim 4.91) (envelope-from ) id 1fxCqK-0001Ab-63; Tue, 04 Sep 2018 17:02:12 +0200 Subject: Re: [PATCH 3/5] drm: fix drm_mode_addfb() on big endian machines. To: Ilia Mirkin Cc: David Airlie , Sean Paul , Gerd Hoffmann , dri-devel , open list 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: =?UTF-8?Q?Michel_D=c3=a4nzer?= Openpgp: preference=signencrypt Autocrypt: addr=michel@daenzer.net; prefer-encrypt=mutual; keydata= mQGiBDsehS8RBACbsIQEX31aYSIuEKxEnEX82ezMR8z3LG8ktv1KjyNErUX9Pt7AUC7W3W0b LUhu8Le8S2va6hi7GfSAifl0ih3k6Bv1Itzgnd+7ZmSrvCN8yGJaHNQfAevAuEboIb+MaVHo 9EMJj4ikOcRZCmQWw7evu/D9uQdtkCnRY9iJiAGxbwCguBHtpoGMxDOINCr5UU6qt+m4O+UD /355ohBBzzyh49lTj0kTFKr0Ozd20G2FbcqHgfFL1dc1MPyigej2gLga2osu2QY0ObvAGkOu WBi3LTY8Zs8uqFGDC4ZAwMPoFy3yzu3ne6T7d/68rJil0QcdQjzzHi6ekqHuhst4a+/+D23h Za8MJBEcdOhRhsaDVGAJSFEQB1qLBACOs0xN+XblejO35gsDSVVk8s+FUUw3TSWJBfZa3Imp V2U2tBO4qck+wqbHNfdnU/crrsHahjzBjvk8Up7VoY8oT+z03sal2vXEonS279xN2B92Tttr AgwosujguFO/7tvzymWC76rDEwue8TsADE11ErjwaBTs8ZXfnN/uAANgPLQjTWljaGVsIERh ZW56ZXIgPG1pY2hlbEBkYWVuemVyLm5ldD6IXgQTEQIAHgUCQFXxJgIbAwYLCQgHAwIDFQID AxYCAQIeAQIXgAAKCRBaga+OatuyAIrPAJ9ykonXI3oQcX83N2qzCEStLNW47gCeLWm/QiPY jqtGUnnSbyuTQfIySkK5AQ0EOx6FRRAEAJZkcvklPwJCgNiw37p0GShKmFGGqf/a3xZZEpjI qNxzshFRFneZze4f5LhzbX1/vIm5+ZXsEWympJfZzyCmYPw86QcFxyZflkAxHx9LeD+89Elx bw6wT0CcLvSv8ROfU1m8YhGbV6g2zWyLD0/naQGVb8e4FhVKGNY2EEbHgFBrAAMGA/0VktFO CxFBdzLQ17RCTwCJ3xpyP4qsLJH0yCoA26rH2zE2RzByhrTFTYZzbFEid3ddGiHOBEL+bO+2 GNtfiYKmbTkj1tMZJ8L6huKONaVrASFzLvZa2dlc2zja9ZSksKmge5BOTKWgbyepEc5qxSju YsYrX5xfLgTZC5abhhztpYhGBBgRAgAGBQI7HoVFAAoJEFqBr45q27IAlscAn2Ufk2d6/3p4 Cuyz/NX7KpL2dQ8WAJ9UD5JEakhfofed8PSqOM7jOO3LCA== Message-ID: <4262e9d1-75c9-1be3-08bd-1ef842a13f2f@daenzer.net> Date: Tue, 4 Sep 2018 17:02:12 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-09-04 3:05 p.m., Ilia Mirkin wrote: > On Tue, Sep 4, 2018 at 4:00 AM, Michel Dänzer wrote: >> 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 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, [...] >> >> As explained before, that would break radeon userspace on big endian hosts. > > 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? ADDFB, not ADDFB2. The latter probably didn't even exist yet when this was made to work. :) -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer