From patchwork Fri Dec 23 14:58:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9487501 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E6AA6601D7 for ; Fri, 23 Dec 2016 14:59:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D955223B3D for ; Fri, 23 Dec 2016 14:59:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CE3D125F3E; Fri, 23 Dec 2016 14:59:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9237F23B3D for ; Fri, 23 Dec 2016 14:59:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9E7F06E076; Fri, 23 Dec 2016 14:59:24 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id A9FC789E19; Fri, 23 Dec 2016 14:58:19 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id c85so3851112wmi.1; Fri, 23 Dec 2016 06:58:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=T/Vdwov7+T/v+f+rmJbOGGTSLtj0xCyY/cbyQ5UrqfE=; b=ZdVgwbR2DVXuUzKe/bdi/Bb/lxkJSYc2rg7ufSyEhXdcfqlM0SsOstmgj13IlFzkXm pf0Hsu3svZDkUutjySfcwSOWoHvplAanxb4fOI6SzUZWHUCW+kWlDQ9ejsY6G1Tqxfc7 DcgWEZCGOHwNKPQ0ChnUhv0rCrrQJFls7BSgIIRINPWSoHWDUssQIB5Ylt1H7AklihXY RGr2TKpHOTxpCsz6dSW8vLM1UaiPnF9T17a8CLRxkP2HuF38FJ6Lx4mc4hQEoJ9c+4P3 a85fEP0HEnAvTUbx/0cgetKGIj777SIcxyg4G+5EEGqb4q7wrp2Rck9qqWmTTAnUkI33 tneQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=T/Vdwov7+T/v+f+rmJbOGGTSLtj0xCyY/cbyQ5UrqfE=; b=ML9xJLRAwQJv0aO78dR6TvupgTHj0Ep9Z1g6HZVQ2ux8WudMffoTy3T69LodTWGNU5 J0g5CqbXPZcE93/VVOKzXynN+zh/YPxxJkbxxldaUYzAaxbPnRVL0DAcz2jvrD7Fl00V krOYN4fyQ8f9VZ7W63MAql+PXJVFab1jLkK21sMEsGErtMrk2gHjrH0YiBl8QeL6Qln7 Zd9x//ZSbaH16c8hlmfh58XpoA6ChmwJSH2bWn3setuD9O7fdaW1fLMaT+QajAO/IcQY bHelBi4xlVJvm+dckBq7A9xILe5Dolkn6e6oQtHA/0ykK/wLmyqAsbe9i55bwMgEmFYG JQAg== X-Gm-Message-State: AIkVDXILvDBqlWAkEz3QkGjuDjsHUgcZnuCycJ2sO2DSRmVzQCnAOHY25DRW+r1bJE0XLg== X-Received: by 10.28.49.193 with SMTP id x184mr13575078wmx.44.1482505097481; Fri, 23 Dec 2016 06:58:17 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id i15sm40786462wjs.16.2016.12.23.06.58.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Dec 2016 06:58:17 -0800 (PST) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Fri, 23 Dec 2016 14:58:04 +0000 Message-Id: <20161223145804.6605-10-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161223145804.6605-1-chris@chris-wilson.co.uk> References: <20161223145804.6605-1-chris@chris-wilson.co.uk> Cc: drm-intel-fixes@lists.freedesktop.org Subject: [Intel-gfx] [PATCH 10/10] drm/i915: Prevent timeline updates whilst performing reset 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-Virus-Scanned: ClamAV using ClamSMTP As the fence may be signaled concurrently from an interrupt on another device, it is possible for the list of requests on the timeline to be modified as we walk it. Take both (the context's timeline and the global timeline) locks to prevent such modifications. Fixes: 80b204bce8f2 ("drm/i915: Enable multiple timelines") Signed-off-by: Chris Wilson Cc: Joonas Lahtinen Cc: Mika Kuoppala Cc: Reviewed-by: Mika Kuoppala --- drivers/gpu/drm/i915/i915_gem.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 94769e3556aa..dba4daaefb94 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2751,6 +2751,7 @@ static void i915_gem_reset_engine(struct intel_engine_cs *engine) struct drm_i915_gem_request *request; struct i915_gem_context *incomplete_ctx; struct intel_timeline *timeline; + unsigned long flags; bool ring_hung; if (engine->irq_seqno_barrier) @@ -2794,13 +2795,20 @@ static void i915_gem_reset_engine(struct intel_engine_cs *engine) if (i915_gem_context_is_default(incomplete_ctx)) return; + timeline = i915_gem_context_lookup_timeline(incomplete_ctx, engine); + + spin_lock_irqsave(&engine->timeline->lock, flags); + spin_lock(&timeline->lock); + list_for_each_entry_continue(request, &engine->timeline->requests, link) if (request->ctx == incomplete_ctx) reset_request(request); - timeline = i915_gem_context_lookup_timeline(incomplete_ctx, engine); list_for_each_entry(request, &timeline->requests, link) reset_request(request); + + spin_unlock(&timeline->lock); + spin_unlock_irqrestore(&engine->timeline->lock, flags); } void i915_gem_reset(struct drm_i915_private *dev_priv)