Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1877626imm; Thu, 7 Jun 2018 01:38:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJmd/kJ95Qt1AsgOZW4L/AfvxLS2Kjdua+552vt5Ha+z/5zOHPvOdzUK64RdqGZMjNPxMkr X-Received: by 2002:a17:902:1002:: with SMTP id b2-v6mr1051496pla.344.1528360707020; Thu, 07 Jun 2018 01:38:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528360706; cv=none; d=google.com; s=arc-20160816; b=b7cM9dQ4x0EQ3xNmlGnWb0A5jylAj///NuGie5TitNfW6QC+iHq7+no6c+NPwnzukj xoSvNo5hKrr2+P9HMvVRw9i4V1l/lRW4ZM8QSBbAsS3kyJXv2kp80IBzE8V4H6qmECgx xQI6UJ2eTr5LRn/h2Dthj85WFkuMapGARhjJlcnUZJ+t3FYo3EmvRV+5ExijhKMCDOyM AFemu8g5NsLHBadXqRBzswl9kFbrMWLqP+P6vZfwYc4/Nnpzn0nrwNHsFuD9w0ylkuOY T8wQXW9EMUVL0fwjmKENy0SXQLjIhYXFuPecywDe7bt9rCUzbn8+K8hkknh0AaTYPADq /YIQ== 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:date:cc:to:from:subject:message-id :arc-authentication-results; bh=SH9i6vDFswcaCppJAnllbHlXAyXRh+wE4Dt/7UOyV5Q=; b=LQUw7askHOZCAgaRyacaqvaCpessI0FKM49Taxl96xiQt6PqOKmeIHQ6n5/IUUR7s+ nygjy4pRZ/R/XTWpNMHJw+Cl+oD6gC+QZc2klqzpYFhdyjymiFiQ/IC3wyNWSYmodFM1 nuUj3Tf8AlXzXNucAMecGq4icWJ+Bv6qVs6BZu6Eox7cNuRa4XO0bhufhy5AQ+tZsp0e G6MA/EBqHg8RGI3Zghibd4JFej1vkDIcqCfjWSZBzORvqqiygDdcis3v2+Jn+eT9qZyG 3XauhhF7a94uQ/dH0iTSpKicL3kMfH/pxJrMIe1XH1eX391atww1f/TPWRemoHUmycaV xWfw== 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 d12-v6si41942327pgq.154.2018.06.07.01.38.12; Thu, 07 Jun 2018 01:38:26 -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; 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 S1753442AbeFGIhn (ORCPT + 99 others); Thu, 7 Jun 2018 04:37:43 -0400 Received: from metis.ext.pengutronix.de ([85.220.165.71]:40575 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752568AbeFGIhj (ORCPT ); Thu, 7 Jun 2018 04:37:39 -0400 Received: from weser.hi.pengutronix.de ([2001:67c:670:100:fa0f:41ff:fe58:4010]) by metis.ext.pengutronix.de with esmtp (Exim 4.89) (envelope-from ) id 1fQqQK-0006Na-9v; Thu, 07 Jun 2018 10:37:36 +0200 Message-ID: <1528360654.15027.2.camel@pengutronix.de> Subject: Re: [PATCH 1/3 v2] drm/v3d: Take a lock across GPU scheduler job creation and queuing. From: Lucas Stach To: Eric Anholt , dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org Date: Thu, 07 Jun 2018 10:37:34 +0200 In-Reply-To: <20180606174851.12433-1-eric@anholt.net> References: <1528274797.26063.6.camel@pengutronix.de> <20180606174851.12433-1-eric@anholt.net> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2001:67c:670:100:fa0f:41ff:fe58:4010 X-SA-Exim-Mail-From: l.stach@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Mittwoch, den 06.06.2018, 10:48 -0700 schrieb Eric Anholt: > Between creation and queueing of a job, you need to prevent any other > job from being created and queued.  Otherwise the scheduler's fences > may be signaled out of seqno order. > > v2: move mutex unlock to the error label. > > > Signed-off-by: Eric Anholt > Fixes: 57692c94dcbe ("drm/v3d: Introduce a new DRM driver for Broadcom V3D V3.x+") Reviewed-by: Lucas Stach > --- >  drivers/gpu/drm/v3d/v3d_drv.h | 5 +++++ >  drivers/gpu/drm/v3d/v3d_gem.c | 4 ++++ >  2 files changed, 9 insertions(+) > > diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/v3d_drv.h > index a043ac3aae98..26005abd9c5d 100644 > --- a/drivers/gpu/drm/v3d/v3d_drv.h > +++ b/drivers/gpu/drm/v3d/v3d_drv.h > @@ -85,6 +85,11 @@ struct v3d_dev { > >    */ > >   struct mutex reset_lock; >   > > + /* Lock taken when creating and pushing the GPU scheduler > > +  * jobs, to keep the sched-fence seqnos in order. > > +  */ > > + struct mutex sched_lock; > + > >   struct { > >   u32 num_allocated; > >   u32 pages_allocated; > diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c > index b513f9189caf..269fe16379c0 100644 > --- a/drivers/gpu/drm/v3d/v3d_gem.c > +++ b/drivers/gpu/drm/v3d/v3d_gem.c > @@ -550,6 +550,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, > >   if (ret) > >   goto fail; >   > > + mutex_lock(&v3d->sched_lock); > >   if (exec->bin.start != exec->bin.end) { > >   ret = drm_sched_job_init(&exec->bin.base, > >    &v3d->queue[V3D_BIN].sched, > @@ -576,6 +577,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, > >   kref_get(&exec->refcount); /* put by scheduler job completion */ > >   drm_sched_entity_push_job(&exec->render.base, > >     &v3d_priv->sched_entity[V3D_RENDER]); > > + mutex_unlock(&v3d->sched_lock); >   > >   v3d_attach_object_fences(exec); >   > @@ -594,6 +596,7 @@ v3d_submit_cl_ioctl(struct drm_device *dev, void *data, > >   return 0; >   >  fail_unreserve: > > + mutex_unlock(&v3d->sched_lock); > >   v3d_unlock_bo_reservations(dev, exec, &acquire_ctx); >  fail: > >   v3d_exec_put(exec); > @@ -615,6 +618,7 @@ v3d_gem_init(struct drm_device *dev) > >   spin_lock_init(&v3d->job_lock); > >   mutex_init(&v3d->bo_lock); > >   mutex_init(&v3d->reset_lock); > > + mutex_init(&v3d->sched_lock); >   > >   /* Note: We don't allocate address 0.  Various bits of HW > >    * treat 0 as special, such as the occlusion query counters