Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp711845ybi; Fri, 2 Aug 2019 03:03:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQ+hbpO48tZg3z6Aw3Rjtxsrde18IYgztSigH1NWmLmyjvPcza4PO1TzzFYByAe1Sa/Vlx X-Received: by 2002:a17:902:740a:: with SMTP id g10mr131550456pll.82.1564740197327; Fri, 02 Aug 2019 03:03:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564740197; cv=none; d=google.com; s=arc-20160816; b=J/NXJKRAitpnPDrV7hflCNK1bLss2Rz4WuriO5zQifuuhjyZ77MRkfqWC5ie2dtNYB /DjcitxpfTohflEX84YyyxgdngbshkFOgEHEAbXX9igsZUJpUcUmfk4N76FNjc2KfazT vkn8sIlOOqgdrwQcSIaz3fzZBYfiWnQxgYZlfebbdhHEN/mlPTCtpnB37F9ye3LJnXwJ XHpESLJjUiSBBquUlTUtuIcg7EDVFYneNZBa68WuwvVV8GamK7yDySbslSR5YuCgeJ9I fIz1RumrWKDbxKRIHF/9o1C7sFVokJv4thwQnbgEf2nSLee52dLj3uIlVyzCsJcaazw9 ew3Q== 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 :in-reply-to:references:mime-version:dkim-signature; bh=A+FPU/vGw66DQH6ItIezOEVqjuBIxZcPX9USWgAb1jM=; b=tP7ik7ZTi1kIsH35RAH28HrLCDw5huKFFI31gHbIYCg4BnWyuO1VEoMSw5I2h7Tl9H fpAAUlzQjQoynLK+X9w+tvbUmV2pFxpEknZpv7zsdLDTjEZ1LLWHh0itd6KYy/fZqrdE aMvKFtuiQNxoD2X4aOSLaICn/t4tfulPanzY14/eH1UZdX1+v6Lj2bpZnBX5s28RFSgK Hbtx1uMMVPwQHnjlZ87paW1w74yW/eb6hPvG3hkXDqWIEykOEa41XTB5FcP7s2fvtukM 19nK61B1KlZmNyB+w+Bk+8etGf1Q39fEwN8Eb2s7aQAVhtpSP6DY+MadSHQ1EwkGQr9/ zDMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=SUOcFbPy; 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 n5si16057154pgq.154.2019.08.02.03.03.00; Fri, 02 Aug 2019 03:03:17 -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=@ffwll.ch header.s=google header.b=SUOcFbPy; 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 S2407119AbfHBKBw (ORCPT + 99 others); Fri, 2 Aug 2019 06:01:52 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:41269 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405130AbfHBJnw (ORCPT ); Fri, 2 Aug 2019 05:43:52 -0400 Received: by mail-oi1-f196.google.com with SMTP id g7so56358152oia.8 for ; Fri, 02 Aug 2019 02:43:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=A+FPU/vGw66DQH6ItIezOEVqjuBIxZcPX9USWgAb1jM=; b=SUOcFbPy5rxss1N6dYEveiIIOMKAwymDOUtmfTGkpGgQ/Xpr3UWjMsAcCCDkBnqdup 1eq2a1R6v6DN0QkaPATZN5n0kE4ue5wnZyoBJTKNOqWawLO3d/A97+DsCdyNlpGcjyQZ XE6laiEawO4BJz5p9iAOjzFnHPln42mGtcH2k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=A+FPU/vGw66DQH6ItIezOEVqjuBIxZcPX9USWgAb1jM=; b=JfDDPrWi/wN4boRyRqx9Y0JlFuTlj1y5P5aVZGsS1Lu8WFNtqhCtwV0ATLwCWqHL9O 2OywW4KvegL/7K/uTSZo9oTDM9KcA9rExdrdnbueAo7b+082m54jBlyhhBtdnhdsEfzz hfFA0AANzINHy02VweSa+9bmM/sk9Fh7HI6TTUPWMfwd6jTkI9tMR2k0os9nrHn8rq7D rRtMb2tl/ifvbl5qtz/LwsuQsc5EWkpl00dsjiHBUy6ofjPzWvRiNGGK9te/a4rf2Rtt +OYZzDR+eVql1Q0lWrSe9f2CWH4Ntwxf4olHhwhRmT/Ox1Q4IaIAwAeNvStE7gFGObf2 UpNw== X-Gm-Message-State: APjAAAUO5/Um9eE6P6/N7nG8zIajxWOJm3eBGpTcmQ1kaeW3SuBE2jWw NV7fEMOnsmJQv/nE4h+JFaJS24K1vDtHfazxqfOANg== X-Received: by 2002:aca:b104:: with SMTP id a4mr2199449oif.14.1564739031061; Fri, 02 Aug 2019 02:43:51 -0700 (PDT) MIME-Version: 1.0 References: <1564571048-15029-1-git-send-email-lowry.li@arm.com> <1564571048-15029-3-git-send-email-lowry.li@arm.com> <20190731132002.dut5mdsqgh7b75iv@DESKTOP-E1NTVVP.localdomain> <20190802092920.4la5cwrltv2m6dke@DESKTOP-E1NTVVP.localdomain> In-Reply-To: <20190802092920.4la5cwrltv2m6dke@DESKTOP-E1NTVVP.localdomain> From: Daniel Vetter Date: Fri, 2 Aug 2019 11:43:39 +0200 Message-ID: Subject: Re: [PATCH v1 2/2] drm: Clear the fence pointer when writeback job signaled To: Brian Starkey Cc: "Lowry Li (Arm Technology China)" , Liviu Dudau , "james qian wang (Arm Technology China)" , "maarten.lankhorst@linux.intel.com" , "seanpaul@chromium.org" , "airlied@linux.ie" , "Julien Yin (Arm Technology China)" , "maxime.ripard@bootlin.com" , "eric@anholt.net" , "kieran.bingham+renesas@ideasonboard.com" , "sean@poorly.run" , "laurent.pinchart@ideasonboard.com" , "Jonathan Chai (Arm Technology China)" , Ayan Halder , "dri-devel@lists.freedesktop.org" , "linux-kernel@vger.kernel.org" , "linux-renesas-soc@vger.kernel.org" , nd 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 Fri, Aug 2, 2019 at 11:29 AM Brian Starkey wrote: > > Hi Lowry, > > On Thu, Aug 01, 2019 at 06:34:08AM +0000, Lowry Li (Arm Technology China) wrote: > > Hi Brian, > > > > On Wed, Jul 31, 2019 at 09:20:04PM +0800, Brian Starkey wrote: > > > Hi Lowry, > > > > > > Thanks for this cleanup. > > > > > > On Wed, Jul 31, 2019 at 11:04:45AM +0000, Lowry Li (Arm Technology China) wrote: > > > > During it signals the completion of a writeback job, after releasing > > > > the out_fence, we'd clear the pointer. > > > > > > > > Check if fence left over in drm_writeback_cleanup_job(), release it. > > > > > > > > Signed-off-by: Lowry Li (Arm Technology China) > > > > --- > > > > drivers/gpu/drm/drm_writeback.c | 23 +++++++++++++++-------- > > > > 1 file changed, 15 insertions(+), 8 deletions(-) > > > > > > > > diff --git a/drivers/gpu/drm/drm_writeback.c b/drivers/gpu/drm/drm_writeback.c > > > > index ff138b6..43d9e3b 100644 > > > > --- a/drivers/gpu/drm/drm_writeback.c > > > > +++ b/drivers/gpu/drm/drm_writeback.c > > > > @@ -324,6 +324,9 @@ void drm_writeback_cleanup_job(struct drm_writeback_job *job) > > > > if (job->fb) > > > > drm_framebuffer_put(job->fb); > > > > > > > > + if (job->out_fence) > > > > > > I'm thinking it might be a good idea to signal the fence with an error > > > here, if it's not already signaled. Otherwise, if there's someone > > > waiting (which there shouldn't be), they're going to be waiting a very > > > long time :-) > > > > > > Thanks, > > > -Brian > > > > > Here it happened at atomic_check failed and test only commit. For both > > cases, the commit has been dropped and it's only a clean up. So here better > > not be treated as an error case:) > > If anyone else has a reference on the fence, then IMO it absolutely is > an error to reach this point without the fence being signaled - > because it means that the fence will never be signaled. > > I don't think the API gives you a way to check if this is the last > reference, so it's safest to just make sure the fence is signalled > before dropping the reference. > > It just feels wrong to me to have the possibility of a dangling fence > which is never going to get signalled; and it's an easy defensive step > to make sure it can never happen. > > I know it _shouldn't_ happen, but we often put in handling for cases > which shouldn't happen, because they frequently do happen :-) We're not as paranoid with the vblank fences either, so not sure why we need to be this paranoid with writeback fences. If your driver grabs anything from the atomic state in ->atomic_check it's buggy anyway. If you want to fix this properly I think we need to move the call to prepare_signalling() in between atomic_check and atomic_commit. Then I think it makes sense to also force-complete the fence on error ... -Daniel > > Since for userspace, it should have been failed or a test only case, so > > writebace fence should not be signaled. > > It's not only userspace that can wait on fences (and in fact this > fence will never even reach userspace if the commit fails), the driver > may have taken a copy to use for "something". > > Cheers, > -Brian > > > > > Best regards, > > Lowry > > > > + dma_fence_put(job->out_fence); > > > > + > > > > kfree(job); > > > > } > > > > -- > > Regards, > > Lowry -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch