From patchwork Fri Oct 9 13:29:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 7361721 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A1D32BEEA4 for ; Fri, 9 Oct 2015 13:29:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A98FA207F0 for ; Fri, 9 Oct 2015 13:29:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id ABE1120561 for ; Fri, 9 Oct 2015 13:29:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6F5766E597; Fri, 9 Oct 2015 06:29:34 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) by gabe.freedesktop.org (Postfix) with ESMTPS id 37E8C6E597 for ; Fri, 9 Oct 2015 06:29:33 -0700 (PDT) Received: from i7.infradead.org ([2001:8b0:10b:1:21e:67ff:fecb:7a92]) by bombadil.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZkXjn-0004fB-Cs; Fri, 09 Oct 2015 13:29:31 +0000 Message-ID: <1444397368.92154.69.camel@infradead.org> From: David Woodhouse To: Jesse Barnes , intel-gfx@lists.freedesktop.org Date: Fri, 09 Oct 2015 14:29:28 +0100 In-Reply-To: <1441385943-11508-8-git-send-email-jbarnes@virtuousgeek.org> References: <1441385943-11508-1-git-send-email-jbarnes@virtuousgeek.org> <1441385943-11508-8-git-send-email-jbarnes@virtuousgeek.org> X-Mailer: Evolution 3.16.5 (3.16.5-3.fc22) Mime-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html Subject: Re: [Intel-gfx] [PATCH 7/9] drm/i915: add fences to the request struct X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, 2015-09-04 at 09:59 -0700, Jesse Barnes wrote: > > @@ -2286,6 +2287,10 @@ struct drm_i915_gem_request { > /** Execlists no. of times this request has been sent to the ELSP */ > int elsp_submitted; > > + /* core fence obj for this request, may be exported */ > + struct fence fence; As discussed, this doesn't work as-is. The final fence_put() will attempt to free(&req->fence). Unless you have a .release method in your fence ops, which you don't. I suppose we could tie up a .release method with the existing release method for the drm_i915_gem_request. As things stand, though, bad things are happening. This makes it go away and at least lets me get on with testing. diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 8ef19e2..2d0c93c 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -2297,7 +2298,7 @@ struct drm_i915_gem_request { int elsp_submitted; /* core fence obj for this request, may be exported */ - struct fence fence; + struct fence *fence; wait_queue_t wait; }; diff --git a/drivers/gpu/drm/i915/i915_sync.c b/drivers/gpu/drm/i915/i915_sync.c index 085f1f9..6ffe273 100644 --- a/drivers/gpu/drm/i915/i915_sync.c +++ b/drivers/gpu/drm/i915/i915_sync.c @@ -58,7 +58,12 @@ struct i915_sync_timeline { * allow non-RCS fences (need ring/context association) */ -#define to_i915_request(x) container_of(x, struct drm_i915_gem_request, fence) +struct foo { + struct fence fence; + struct drm_i915_gem_request *req; +}; + +#define to_i915_request(x) (((struct foo *)(x))->req) static const char *i915_fence_get_driver_name(struct fence *fence) { @@ -81,10 +86,10 @@ static int i915_fence_ring_check(wait_queue_t *wait, unsigned mode, int flags, if (!i915_gem_request_completed(req, false)) return 0; - fence_signal_locked(&req->fence); + fence_signal_locked(req->fence); __remove_wait_queue(&ring->irq_queue, wait); - fence_put(&req->fence); + fence_put(req->fence); ring->irq_put(ring); return 0; @@ -200,6 +205,15 @@ struct fence *i915_fence_create_ring(struct intel_engine_cs *ring, if (ret) return ERR_PTR(ret); + request->fence = kmalloc(sizeof(struct foo), GFP_KERNEL); + if (!request->fence) { + ret = -ENOMEM; + goto err_cancel; + } + /* I have no clue how this is *supposed* to work and no real interest + in finding out. Just stop hurting me please. */ + ((struct foo *)request->fence)->req = request; + if (i915.enable_execlists) { ringbuf = ctx->engine[ring->id].ringbuf; } else @@ -270,10 +284,10 @@ struct fence *i915_fence_create_ring(struct intel_engine_cs *ring, round_jiffies_up_relative(HZ)); intel_mark_busy(dev_priv->dev); - fence_init(&request->fence, &i915_fence_ring_ops, &fence_lock, + fence_init(request->fence, &i915_fence_ring_ops, &fence_lock, ctx->user_handle, request->seqno); - return &request->fence; + return request->fence; err_cancel: i915_gem_request_cancel(request); @@ -306,10 +320,10 @@ static struct fence *i915_fence_create_display(struct intel_context *ctx) req = ring->outstanding_lazy_request; - fence_init(&req->fence, &i915_fence_ops, &fence_lock, + fence_init(req->fence, &i915_fence_ops, &fence_lock, ctx->user_handle, req->seqno); - return &req->fence; + return req->fence; } #endif