From patchwork Fri Dec 12 16:13:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Gordon X-Patchwork-Id: 5483731 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 868F39F1D4 for ; Fri, 12 Dec 2014 16:13:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0ACF2017D for ; Fri, 12 Dec 2014 16:13:30 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id BE30920172 for ; Fri, 12 Dec 2014 16:13:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 370C36E9AC; Fri, 12 Dec 2014 08:13:29 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 269776E9AC for ; Fri, 12 Dec 2014 08:13:28 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 12 Dec 2014 08:11:24 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,691,1406617200"; d="scan'208";a="497860862" Received: from dsgordon-linux.isw.intel.com ([10.102.226.149]) by orsmga003.jf.intel.com with ESMTP; 12 Dec 2014 08:09:31 -0800 From: Dave Gordon To: intel-gfx@lists.freedesktop.org Date: Fri, 12 Dec 2014 16:13:02 +0000 Message-Id: <1418400783-5524-3-git-send-email-david.s.gordon@intel.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1418400783-5524-1-git-send-email-david.s.gordon@intel.com> References: <1418400783-5524-1-git-send-email-david.s.gordon@intel.com> Subject: [Intel-gfx] [PATCH 2/3] drm/i915: recheck ringspace after wait+retire 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: , MIME-Version: 1.0 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 In {intel,logical}_ring_wait_request(), we try to find a request whose completion will release the amount of ring space required. If we find such a request, we wait for it, and then retire it, in the expectation that we will now have at least the required amount of free space in the ring. But it's good to check that this has actually happened, so we can back out with a meaningful error code if something unexpected has happened, such as wait_request returning early. This code was already in the execlist version, so the change to intel_lrc.c is just to add a comment; but we want the same check in the legacy ringbuffer mode too. Signed-off-by: Dave Gordon --- drivers/gpu/drm/i915/intel_lrc.c | 9 +++++++++ drivers/gpu/drm/i915/intel_ringbuffer.c | 12 +++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 8545dbd..69b042f 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c @@ -956,6 +956,15 @@ static int logical_ring_wait_request(struct intel_ringbuffer *ringbuf, i915_gem_retire_requests_ring(ring); + /* + * According to our calculation above, retiring the request we just + * waited for should have resulted in there being enough space in + * the ringbuffer; but let's check. + * + * If there is not now enough space, something has gone horribly worng + * (such as wait_request returning early, but with no error, or + * retire_requests failing to retire the request we expected it to). + */ return intel_ring_space(ringbuf) >= bytes ? 0 : -ENOSPC; } diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c index 9def83c..660d10d 100644 --- a/drivers/gpu/drm/i915/intel_ringbuffer.c +++ b/drivers/gpu/drm/i915/intel_ringbuffer.c @@ -1912,6 +1912,7 @@ static int intel_ring_wait_request(struct intel_engine_cs *ring, int n) return 0; list_for_each_entry(request, &ring->request_list, list) { + /* Would completion of this request free enough space? */ if (__intel_ring_space(request->tail, ringbuf->tail, ringbuf->effective_size) >= n) { break; @@ -1927,7 +1928,16 @@ static int intel_ring_wait_request(struct intel_engine_cs *ring, int n) i915_gem_retire_requests_ring(ring); - return 0; + /* + * According to our calculation above, retiring the request we just + * waited for should have resulted in there being enough space in + * the ringbuffer; but let's check. + * + * If there is not now enough space, something has gone horribly worng + * (such as wait_request returning early, but with no error, or + * retire_requests failing to retire the request we expected it to). + */ + return intel_ring_space(ringbuf) >= n ? 0 : -ENOSPC; } static int ring_wait_for_space(struct intel_engine_cs *ring, int n)