From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9219E1FA857 for ; Mon, 2 Dec 2024 09:22:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733131361; cv=none; b=CycWS7q2mRCYCE0QsurX7zYBkyVzfkcIm/I75UeXyUVUI+WFzbtf+wu+sN/Xdjo/dM4lFPD6New5wDM4Ze2+uyNv8SJcFbGshfEx10lC3ScxMZcYtRXzDAYU1HOOYyrNd//BDE9McTwPu4KM9/cNJviM4wIUR9cmr8eo4F04A+Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733131361; c=relaxed/simple; bh=YDSKzOOX2ioPbI+g4xmEkyWIV44JCFQKlGuOTGFtBbc=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YbAQg1JLGKJz6vrCYFdXxi0O2Vp9AjvRuSg3ZLPbgJUX37zt6uhewsFlIxUBPf6iNPTTUo4gIG9R3ecopU586yXKGgNgPYML9IW9PrhKWhunQOYrwNSNYDWBODEI24DttKkKk0Z+eB39irbPEwU18B/7dR2ZFs9/wNOaEz+IcvM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=P+/p7Rq3; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="P+/p7Rq3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1733131352; bh=YDSKzOOX2ioPbI+g4xmEkyWIV44JCFQKlGuOTGFtBbc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=P+/p7Rq3Be2zY1Nk7hrHoRdVqDeGSomvgG9BKXr2maNACkaZuKihbJrXfKi6LR4yf XDjH5o0cL1Z3JDmdGIa+EaQwEuDuFC8A1Ekhk4FJuib0qS3G3SvZ7KETP9tKAHXE5w ZDuZWoNL1VHPmugQHJY6iQsS2YMO5destxUUTCNt3bBh/EBxTtnAZ9cnQrdRfR4ucZ iXCnk+Ait8+CUixMRpY4KgWEDbfiHhhdcyNx0PutdZAhz0Ja3sxcyP6sN6LA/LVH84 LGohZC2d2Ez7j8Aidz3OnHRFXJnFbOneE/bYa6zjnb6QA0cbPgInVqJIiwWLMKP81o qYuH86axLntNQ== Received: from localhost (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbrezillon) by bali.collaboradmins.com (Postfix) with ESMTPSA id DF7AF17E14EA; Mon, 2 Dec 2024 10:22:31 +0100 (CET) Date: Mon, 2 Dec 2024 10:21:51 +0100 From: Boris Brezillon To: =?UTF-8?B?QWRyacOhbg==?= Larumbe Cc: Rob Herring , Steven Price , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Philipp Zabel , kernel@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 3/8] drm/panfrost: Handle job HW submit errors Message-ID: <20241202102151.41cc3d4f@collabora.com> In-Reply-To: <20241128211223.1805830-4-adrian.larumbe@collabora.com> References: <20241128211223.1805830-1-adrian.larumbe@collabora.com> <20241128211223.1805830-4-adrian.larumbe@collabora.com> Organization: Collabora X-Mailer: Claws Mail 4.3.0 (GTK 3.24.43; x86_64-redhat-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, 28 Nov 2024 21:06:18 +0000 Adri=C3=A1n Larumbe wrote: > Avoid waiting for the DRM scheduler job timedout handler, and instead, let > the DRM scheduler core signal the error fence immediately when HW job > submission fails. >=20 > That means we must also decrement the runtime-PM refcnt for the device, > because the job will never be enqueued or inflight. >=20 > Signed-off-by: Adri=C3=A1n Larumbe > --- > drivers/gpu/drm/panfrost/panfrost_job.c | 20 ++++++++++++++++---- > 1 file changed, 16 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/pa= nfrost/panfrost_job.c > index f640d211cc3a..3f4f0682d69d 100644 > --- a/drivers/gpu/drm/panfrost/panfrost_job.c > +++ b/drivers/gpu/drm/panfrost/panfrost_job.c > @@ -195,7 +195,7 @@ panfrost_enqueue_job(struct panfrost_device *pfdev, i= nt slot, > return 1; > } > =20 > -static void panfrost_job_hw_submit(struct panfrost_job *job, int js) > +static int panfrost_job_hw_submit(struct panfrost_job *job, int js) > { > struct panfrost_device *pfdev =3D job->pfdev; > unsigned int subslot; > @@ -207,10 +207,11 @@ static void panfrost_job_hw_submit(struct panfrost_= job *job, int js) > =20 > ret =3D pm_runtime_get_sync(pfdev->base.dev); > if (ret < 0) > - return; > + goto err_hwsubmit; > =20 > if (WARN_ON(job_read(pfdev, JS_COMMAND_NEXT(js)))) { > - return; > + ret =3D -EINVAL; > + goto err_hwsubmit; > } > =20 > cfg =3D panfrost_mmu_as_get(pfdev, job->mmu); > @@ -261,6 +262,12 @@ static void panfrost_job_hw_submit(struct panfrost_j= ob *job, int js) > job, js, subslot, jc_head, cfg & 0xf); > } > spin_unlock(&pfdev->js->job_lock); > + > + return 0; > + > +err_hwsubmit: > + pm_runtime_put_autosuspend(pfdev->base.dev); > + return ret; > } > =20 > static int panfrost_acquire_object_fences(struct drm_gem_object **bos, > @@ -382,6 +389,7 @@ static struct dma_fence *panfrost_job_run(struct drm_= sched_job *sched_job) > struct panfrost_device *pfdev =3D job->pfdev; > int slot =3D panfrost_job_get_slot(job); > struct dma_fence *fence =3D NULL; > + int ret; > =20 > if (unlikely(job->base.s_fence->finished.error)) > return NULL; > @@ -400,7 +408,11 @@ static struct dma_fence *panfrost_job_run(struct drm= _sched_job *sched_job) > dma_fence_put(job->done_fence); > job->done_fence =3D dma_fence_get(fence); > =20 > - panfrost_job_hw_submit(job, slot); > + ret =3D panfrost_job_hw_submit(job, slot); > + if (ret) { > + dma_fence_put(job->done_fence); If you call dma_fence_put() here, you need to set job->done_fence to NULL, otherwise dma_fence_put() will be called again on an already freed fence in panfrost_job_cleanup(). Question is, do we really need to call dma_fence_put(job->done_fence) here? Can't we let the job destructor take care of that? > + return ERR_PTR(ret); > + } > =20 > return fence; > }