From mboxrd@z Thu Jan 1 00:00:00 1970 From: "james qian wang (Arm Technology China)" Subject: Re: [PATCH v1 2/2] drm: Clear the fence pointer when writeback job signaled Date: Fri, 2 Aug 2019 10:09:26 +0000 Message-ID: <20190802100919.GA26225@jamwan02-TSP300> 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> <20190801063351.GB17887@lowry.li@arm.com> <20190802092920.4la5cwrltv2m6dke@DESKTOP-E1NTVVP.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Return-path: In-Reply-To: <20190802092920.4la5cwrltv2m6dke@DESKTOP-E1NTVVP.localdomain> Content-Language: en-US Content-ID: Sender: linux-kernel-owner@vger.kernel.org To: Brian Starkey Cc: "Lowry Li (Arm Technology China)" , Liviu Dudau , "maarten.lankhorst@linux.intel.com" , "seanpaul@chromium.org" , "airlied@linux.ie" , "daniel@ffwll.ch" , "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.freedes List-Id: dri-devel@lists.freedesktop.org On Fri, Aug 02, 2019 at 05:29:20PM +0800, Brian Starkey wrote: > Hi Lowry, >=20 > On Thu, Aug 01, 2019 at 06:34:08AM +0000, Lowry Li (Arm Technology China)= wrote: > > Hi Brian, > >=20 > > On Wed, Jul 31, 2019 at 09:20:04PM +0800, Brian Starkey wrote: > > > Hi Lowry, > > >=20 > > > Thanks for this cleanup. > > >=20 > > > On Wed, Jul 31, 2019 at 11:04:45AM +0000, Lowry Li (Arm Technology Ch= ina) wrote: > > > > During it signals the completion of a writeback job, after releasin= g > > > > the out_fence, we'd clear the pointer. > > > >=20 > > > > Check if fence left over in drm_writeback_cleanup_job(), release it= . > > > >=20 > > > > Signed-off-by: Lowry Li (Arm Technology China) > > > > --- > > > > drivers/gpu/drm/drm_writeback.c | 23 +++++++++++++++-------- > > > > 1 file changed, 15 insertions(+), 8 deletions(-) > > > >=20 > > > > 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_write= back_job *job) > > > > if (job->fb) > > > > drm_framebuffer_put(job->fb); > > > > =20 > > > > + if (job->out_fence) > > >=20 > > > I'm thinking it might be a good idea to signal the fence with an erro= r > > > 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 ver= y > > > long time :-) > > >=20 > > > Thanks, > > > -Brian > > >=20 > > 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 be= tter > > not be treated as an error case:) >=20 > 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. >=20 > 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. >=20 > 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. >=20 > I know it _shouldn't_ happen, but we often put in handling for cases > which shouldn't happen, because they frequently do happen :-) >=20 > >=20 > > Since for userspace, it should have been failed or a test only case, so > > writebace fence should not be signaled. >=20 > 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". > Maybe we can add a wb_fence canceling into complete_signaling() for the atomic_check failed cleanup like the crtc->out_fence. Then if in this place we still can got a fence here, that must be a error we signal and WARN it Thanks James > Cheers, > -Brian >=20 > >=20 > > Best regards, > > Lowry > > > > + dma_fence_put(job->out_fence); > > > > + > > > > kfree(job); > > > > } > >=20 > > --=20 > > Regards > > Lowry