Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp482194imu; Mon, 26 Nov 2018 13:43:20 -0800 (PST) X-Google-Smtp-Source: AFSGD/U8eJcEQUJRDV2JFYKWIKneEcOM1+N/kGdrV1OeKnKzl0mZaquFtT8bespQ3HlMKhyS0f7i X-Received: by 2002:a63:62c3:: with SMTP id w186mr26873341pgb.345.1543268600887; Mon, 26 Nov 2018 13:43:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543268600; cv=none; d=google.com; s=arc-20160816; b=Z4CL8s722fiqfm4/sT7aAlDQG+JIUC/y8LuR9htCFZce6G7FHBhFVNaVXmGHgYQePw BtSUNVhdEnDDriEebObX0kfaon3EFkVi2Hv8MTuotp6WIsDFNmPwXCr6/n22dtvOoR8l mXKeHmBkjT6CHfZg7jxYhA8+oQgNkmojCpcjCBSFAsaegycPdiEKaAFjvtXmxOHIYxXq cWrKr5eWWLGUY40J/fTqAPKXGWqTOuxLOCN/cS36dibJ9Fczwo1ei1E6p5sXxS/iEmsG +qCHiaEqJNJUrbChETCe1PPMQcjjC0uiQmyD6GazO8V2nPEt7Z3krWTfY1m/4UVzVTMB Niiw== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=KUpmca/hM6k+SiR2dbdztBPTIXCk47r+s+sEMpjWPAE=; b=1KdtcFTGE+dCamBKH2hIeRCzwEL6FbRavJ6u2Hd8dTlZvwZrTjvQ1EeRmWSrtMPuvn LHVVtUYEH3Ep/b2Jglvw31lCgDeuWHRSpssXYzqI8MjDTQh6OJ0vPUoDikdjmdMSs2Fo PvShwKnowOpDR88oKKmpaJ0gX0s1QB0lmVG1p9MNypL/hTLBcaMVV2IHS1qTATz4G2hk Sr8+ZjIZ/1QIOtN1iZoipdV+cgtJGJMmwhUpisuHf4p8eFkUJ3i3UwTePdOe5/Bl99wS qf67L+LAWbepX2WQLU53i5ZmSjc4LWEb6BdkfXxdLqewI0jHRaXhcvD8dBZB/PME89+h B56Q== 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 64si1515321ply.372.2018.11.26.13.43.06; Mon, 26 Nov 2018 13:43:20 -0800 (PST) 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 S1726924AbeK0Igo (ORCPT + 99 others); Tue, 27 Nov 2018 03:36:44 -0500 Received: from mail.bootlin.com ([62.4.15.54]:43500 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726315AbeK0Igo (ORCPT ); Tue, 27 Nov 2018 03:36:44 -0500 Received: by mail.bootlin.com (Postfix, from userid 110) id 8EC15207BB; Mon, 26 Nov 2018 22:41:13 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.2 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) by mail.bootlin.com (Postfix) with ESMTPSA id 2B17E206D8; Mon, 26 Nov 2018 22:41:03 +0100 (CET) Date: Mon, 26 Nov 2018 22:41:02 +0100 From: Boris Brezillon To: Eric Anholt Cc: Michael Zoran , Tomasz Figa , helen.koike@collabora.com, Sandy Huang , Heiko =?UTF-8?B?U3TDvGJuZXI=?= , David Airlie , "list\@263.net\:IOMMU DRIVERS \\, Joerg Roedel \\," , "list\@263.net\:IOMMU DRIVERS \\, Joerg Roedel \\," , "list\@263.net\:IOMMU DRIVERS \\, Joerg Roedel \\," , Enric Balletbo i Serra , Linux Kernel Mailing List , dri-devel , "open list\:ARM\/Rockchip SoC..." , Gustavo Padovan , Sean Paul , kernel@collabora.com, =?UTF-8?B?U3TDqXBoYW5l?= Marchesin Subject: Re: [PATCH v3] drm/rockchip: update cursors asynchronously through atomic. Message-ID: <20181126224102.1efbf2d1@bbrezillon> In-Reply-To: <87o9abbmq4.fsf@anholt.net> References: <20181119190805.19139-1-helen.koike@collabora.com> <1d10a4323a49ca09bbb7dc865aaaf5b8c5e3b3d5.camel@crowfest.net> <87o9abbmq4.fsf@anholt.net> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 26 Nov 2018 12:36:03 -0800 Eric Anholt wrote: > Michael Zoran writes: > > > On Fri, 2018-11-23 at 11:27 +0900, Tomasz Figa wrote: > >> > >> The point here is not about setting and resetting the plane->fb > >> pointer. It's about what happens inside > >> drm_atomic_set_fb_for_plane(). > >> > >> It calls drm_framebuffer_get() for the new fb and > >> drm_framebuffer_put() for the old fb. In result, if the fb changes, > >> the old fb, which had its reference count incremented in the atomic > >> commit that set it to the plane before, has its reference count > >> decremented. Moreover, if the new reference count becomes 0, > >> drm_framebuffer_put() will immediately free the buffer. > >> > >> Freeing a buffer when the hardware is still scanning out of it isn't > >> a > >> good idea, is it? > > > > No, it's not. But the board I submitted the patch for doesn't have > > anything like hot swapable ram. The ram access is still going to work, > > just it might display something it shouldn't. Say for example if that > > frame buffer got reused by somethig else and filled with new data in > > the very small window. > > > > But yes, I agree the best solution would be to not release the buffer > > until the next vblank. > > > > Perhaps a good solution would be for the DRM api to have the concept of > > a deferred release? Meaning if the put() call just added the frame > > buffer to a list that DRM core could walk during the vblank. That > > might be better then every single driver trying to work up a custom > > solution. > > > >> The vc4 driver seems to be able to program the hardware to switch the > >> scanout to the new buffer immediately: > >> > >> https://elixir.bootlin.com/linux/v4.20-rc3/source/drivers/gpu/drm/vc4/vc4_plane.c#L794 > >> > >> Although I wonder if there isn't still a tiny race there - the > >> hardware may have just started refilling the FIFO from the old > >> address. Still, if the FIFO is small, the FIFO refill operation may > >> be > >> much shorter than it takes for the kernel code to actually free the > >> buffer. Eric and Michael, could you confirm? > >> > > > > I don't have those boards anymore, and I don't have access to any > > technical documentation on the GPU so I can't really add much here. > > Eric can probably provide the best information. > > I don't think I understood my scanout hardware well enough when I > started on the async update stuff for rpi. vc4 probably needs to wait > until the HW starts scanning out a new line before letting the old BO > get freed. That's also my understanding. Note that even if the BO is freed before the HVS has finished generating a line it shouldn't crash, because accesses are done through DMA. Might be a security issue though if we start re-using the memory for something else while it's still being accessed. The solution would be to wait for the EOL (End Of Line) interrupt in the async update path, but I'm not sure this is allowed.