Received: by 10.213.65.68 with SMTP id h4csp53407imn; Thu, 5 Apr 2018 17:38:18 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+1dmnBHNRpv0PfDkpTluKGu0SVhoH9SYLIikk/tyFVYvEgL7oADLEpweXW17IO0VrwvxsB X-Received: by 10.101.88.78 with SMTP id s14mr1914878pgr.97.1522975098399; Thu, 05 Apr 2018 17:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522975098; cv=none; d=google.com; s=arc-20160816; b=Tkt9Opvoj/RaYxEzpmSv1mc+Dfg7JacgfZEn39huXKcBbxCf0NtmY1C2Msn4EyN60R aplq81LXUSwlf6vslS8w1bqJoXDwdVusocacjhppYbdogBIaYd+94kmyCrHcZZwvyaRY E1DtHXHLNfy0XBhrxnGlDUrIQ3ua0QD/PZKzgT/VEReNhQ4vy+We6CIUzt6jaBRORuL5 gHaHRsAJDTXE671c5dl08JVI2IyS9oR8RnlH0W7BgdI56Y8j/EcKw6Q6frEbAev5dxk5 WFxbsuARTkfiKAoq6a9Soptg3AXXgUzrcWW19+vPLuuTErzJRDgIuyHc/sQS2aL++pGp flfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=J3jNU4NMjXJMenGMz73GY1M7WHQPlqmdYs1nzltveOg=; b=rqlZET0SyZhsLHkgb+F9vie5IX5HmuCyqltV7kNRVhY07uXBwOG4SQ8mhJKPXFq5jZ lzeP8L1WvRviI+DI7gqtDLka1tSgbAApanT23Em8hz+nbFSE+GArAOdKZHQVjJW9NaoO AYTrOZ0L4ba0X648hODyorOts6Hs6nV0aJgvvIo8NQZELd69nCHAeDCOnlZYZjSVeo6V w+Fm6Q4uHnBNl9/xLBAgm9j4JoL2qeTRzxw2NyVIYrszFiJ8Tx6Zq1knl/NJ+cyczbAg BosqrAbWmCVR97+USZtZWddtD5bU8awKEf2x/o/xGm6DkXVYwhvxIBiqZqaG3iXknwjd oz4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YpXP9ce+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p125si6224742pga.396.2018.04.05.17.38.03; Thu, 05 Apr 2018 17:38:18 -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=pass header.i=@gmail.com header.s=20161025 header.b=YpXP9ce+; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751410AbeDFAg7 (ORCPT + 99 others); Thu, 5 Apr 2018 20:36:59 -0400 Received: from mail-io0-f170.google.com ([209.85.223.170]:46461 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751179AbeDFAg6 (ORCPT ); Thu, 5 Apr 2018 20:36:58 -0400 Received: by mail-io0-f170.google.com with SMTP id q80so32693039ioi.13; Thu, 05 Apr 2018 17:36:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=J3jNU4NMjXJMenGMz73GY1M7WHQPlqmdYs1nzltveOg=; b=YpXP9ce+5BHBKzx+r/uHwGb+hfXguJk26JOBMKMe72k3Io80XR2JBUAoAidAuKoZbl IbZvxDEn/Qj5BDfkPetvFfy4xyY3SbX9fulc9m+mFZa7abJ8xUL1pZh1KMuShsW0rS40 nYiUJbcEW/1XdBK+Af1x+mixbwt8FVV9KV5hL1DaphhXdUC11O3JF7veY/N83Rz35dMA w3RkKRdGJbC/hFYAUYMemx3DZF1Cr9c2AH3GOKxpN5zrDq+3PLdpdPIguU2LatO36r3l IgbeWnK2ZOYmfGhwHK6j1jpag+50nXK4NJouQYjoQ1BintKGa3HtLw2z63XjqM/7ZLLp 5j2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=J3jNU4NMjXJMenGMz73GY1M7WHQPlqmdYs1nzltveOg=; b=YoJwIaawC0FuvWOV4Sw5OavQA1WW0yQUVaw2qApNNKCgk94sGQcotNdlh07uOfDBkz amfCFwqg1RnnpL4t2gXcbgc9bKEsYdfux/kwLQlwtLB/U5/kzmaL7ckFvNXShqVicZ6t eDobb1HjkOGi56KnCRfELA9VrZV+Db6vAKNgAEZRB/hOO/aPkPIl6hycONNX5eu1u3dQ PkqZ1HC2JQIj8RkLpixeD1zc7BwlM+4oYjNhtrtWb9vHsF3QoTggv8OVSXABb4i4Bk+n arwnDEuMLwbCxI68jUdH6dSF+KAsTWK1LMD1Z8yed9JHryO/nFFdDqBoR3UK2QT1wmuc z9Xw== X-Gm-Message-State: ALQs6tDqs9DTvzOTJ2iZDEXwy1B2kkQfJAEclZRFoaIfkOcz/WIy4UFe 93tMsW0xW1TxDxK7zKHMWx81udFkw9sm36Sfo2U= X-Received: by 10.107.3.71 with SMTP id 68mr24224326iod.66.1522975017085; Thu, 05 Apr 2018 17:36:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.213.85.204 with HTTP; Thu, 5 Apr 2018 17:36:56 -0700 (PDT) In-Reply-To: <7616bf87-bd2e-5003-af35-bc95f0e2a912@shipmail.org> References: <20180403224225.26776-1-robdclark@gmail.com> <307adb15-412a-1fe2-f116-27fe5b4a657d@shipmail.org> <20180404084320.GA3881@phenom.ffwll.local> <20180404095604.GD3881@phenom.ffwll.local> <7616bf87-bd2e-5003-af35-bc95f0e2a912@shipmail.org> From: Rob Clark Date: Thu, 5 Apr 2018 20:36:56 -0400 Message-ID: Subject: Re: [RFC] drm/atomic+msm: add helper to implement legacy dirtyfb To: Thomas Hellstrom Cc: =?UTF-8?Q?Noralf_Tr=C3=B8nnes?= , dri-devel , freedreno , linux-arm-msm , =?UTF-8?B?VmlsbGUgU3lyasOkbMOk?= , Lukasz Spintzyk , Deepak Singh Rawat , Gustavo Padovan , Maarten Lankhorst , Sean Paul , David Airlie , Linux Kernel Mailing List 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 Thu, Apr 5, 2018 at 9:30 AM, Thomas Hellstrom wrote: > On 04/04/2018 11:56 AM, Daniel Vetter wrote: >> >> On Wed, Apr 04, 2018 at 11:10:08AM +0200, Thomas Hellstrom wrote: >>> >>> On 04/04/2018 10:43 AM, Daniel Vetter wrote: >>>> >>>> On Wed, Apr 04, 2018 at 10:22:21AM +0200, Thomas Hellstrom wrote: >>>>> >>>>> Hi, >>>>> >>>>> On 04/04/2018 08:58 AM, Daniel Vetter wrote: >>>>>> >>>>>> On Wed, Apr 4, 2018 at 12:42 AM, Rob Clark >>>>>> wrote: >>>>>>> >>>>>>> Add an atomic helper to implement dirtyfb support. This is needed to >>>>>>> support DSI command-mode panels with x11 userspace (ie. when we can't >>>>>>> rely on pageflips to trigger a flush to the panel). >>>>>>> >>>>>>> To signal to the driver that the async atomic update needs to >>>>>>> synchronize with fences, even though the fb didn't change, the >>>>>>> drm_atomic_state::dirty flag is added. >>>>>>> >>>>>>> Signed-off-by: Rob Clark >>>>>>> --- >>>>>>> Background: there are a number of different folks working on getting >>>>>>> upstream kernel working on various different phones/tablets with qcom >>>>>>> SoC's.. many of them have command mode panels, so we kind of need a >>>>>>> way to support the legacy dirtyfb ioctl for x11 support. >>>>>>> >>>>>>> I know there is work on a proprer non-legacy atomic property for >>>>>>> userspace to communicate dirty-rect(s) to the kernel, so this can >>>>>>> be improved from triggering a full-frame flush once that is in >>>>>>> place. But we kinda needa a stop-gap solution. >>>>>>> >>>>>>> I had considered an in-driver solution for this, but things get a >>>>>>> bit tricky if userspace ands up combining dirtyfb ioctls with page- >>>>>>> flips, because we need to synchronize setting various CTL.FLUSH bits >>>>>>> with setting the CTL.START bit. (ie. really all we need to do for >>>>>>> cmd mode panels is bang CTL.START, but is this ends up racing with >>>>>>> pageflips setting FLUSH bits, then bad things.) The easiest soln >>>>>>> is to wrap this up as an atomic commit and rely on the worker to >>>>>>> serialize things. Hence adding an atomic dirtyfb helper. >>>>>>> >>>>>>> I guess at least the helper, with some small addition to translate >>>>>>> and pass-thru the dirty rect(s) is useful to the final atomic dirty- >>>>>>> rect property solution. Depending on how far off that is, a stop- >>>>>>> gap solution could be useful. >>>>>> >>>>>> Adding Noralf, who iirc already posted the full dirty helpers already >>>>>> somewhere. >>>>>> -Daniel >>>>> >>>>> I've asked Deepak to RFC the core changes suggested for the full dirty >>>>> blob >>>>> on dri-devel. It builds on DisplayLink's suggestion, with a simple >>>>> helper to >>>>> get to the desired coordinates. >>>>> >>>>> One thing to perhaps discuss is how we would like to fit this with >>>>> front-buffer rendering and the dirty ioctl. In the page-flip context, >>>>> the >>>>> dirty rects, like egl's swapbuffer_with_damage is a hint to restrict >>>>> the >>>>> damage region that can be fully ignored by the driver, new content is >>>>> indicated by a new framebuffer. >>>>> >>>>> We could do the same for frontbuffer rendering: Either set a dirty flag >>>>> like >>>>> you do here, or provide a content_age state member. Since we clear the >>>>> dirty >>>>> flag on state copies, I guess that would be sufficient. The blob >>>>> rectangles >>>>> would then become a hint to restrict the damage region. >>>> >>>> I'm not entirely following here - I thought for frontbuffer rendering >>>> the >>>> dirty rects have always just been a hint, and that the driver was always >>>> free to re-upload the entire buffer to the screen. >>>> >>>> And through a helper like Rob's proposing here (and have floated around >>>> in >>>> different versions already) we'd essentially map a frontbuffer dirtyfb >>>> call to a fake flip with dirty rect. Manual upload drivers already need >>>> to >>>> upload the entire screen if they get a flip, since some userspace uses >>>> that to flush out frontbuffer rendering (instead of calling dirtyfb). >>>> >>>> So from that pov the new dirty flag is kinda not necessary imo. >>>> >>>>> Another approach would be to have the presence of dirty rects without >>>>> framebuffer change to indicate frontbuffer rendering. >>>>> >>>>> I think I like the first approach best, although it may be tempting for >>>>> user-space apps to just set the dirty bit instead of providing the full >>>>> damage region. >>>> >>>> Or I'm not following you here, because I don't quite see the difference >>>> between dirtyfb and a flip. >>>> -Daniel >>> >>> OK, let me rephrase: >>> >>> From the driver's point-of-view, in the atomic world, new content and >>> the >>> need for manual upload is indicated by a change in fb attached to the >>> plane. >>> >>> With Rob's patch here, (correct me if I'm wrong) in addition new content >>> and >>> the need for manual upload is identified by the dirty flag, (since the fb >>> stays the same and the driver thus never identifies a page-flip). >> >> Hm, I'm not entirely sure Rob's approach is correct. Imo a pageflip >> (atomic or not) should result in the entire buffer getting uploaded. The >> dirty flag is kinda redundant, a flip with the same buffer works the same >> way as a dirtyfb with the entire buffer as the dirty rectangle. >> >>> In both these situations, clip rects can provide a hint to restrict the >>> dirty region. >>> >>> Now I was thinking about the preferred way for user-space to communicate >>> front buffer rendering through the atomic ioctl: >>> >>> 1) Expose a dirty (or content_age property) >>> 2) Attach a clip-rect blob property. >>> 3) Fake a page-flip by ping-ponging two frame-buffers pointing to the >>> same >>> underlying buffer object. >>> >>> Are you saying that people are already using 3) and we should keep using >>> that? >> >> I'm saying they're using 3b), flip the same buffer wrapped in the same >> drm_framebuffer, and expect it to work. >> >> The only advantage dirtyfb has is that it allows you to supply the >> optimized upload rectangles, but at the cost of a funny api (it's working >> on the fb, not the plane/crtc you want to upload) and lack of drm_event to >> confirm when exactly you uploaded your stuff. But imo they should be the >> same underlying operation. >> > > FWIW, vmwgfx has always treated a dirtyfb as a pure front-buffer like > rendering operation without any synchronization, I guess this works for you because dirtyfb msg to host and rendering msgs to host end up serialized? > We've guaranteed that only the rects that are present are uploaded, but only > xf86-video-vmware has taken advantage of this to keep > CPU- and GPU rendered content apart. > I think we've at some point run into problems with number of cliprects, (Old > KDE lock screen?) and use multiple dirtyfb for the same > update... fwiw, I haven't really looked at how it works on msm yet.. my memories from omap where that we could set a single clip-rect on tx to panel but we'd need to block tx of contents of next clip-rect until previous was finished, so we kinda have a limit of 1.. and I expect msm (or most other dsi drivers) are similar.. but I'm expecting that serializing everything on atomic commit worker helps here BR, -R > > IIRC the reason for working with the fb, is that it's much easier for > user-space, which doesn't have to care where planes are scanning out and > why. > "Present my new content on any screen that's affected". > > /Thomas > >