From patchwork Wed Jul 4 20:18:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1157281 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 4375E40ABE for ; Wed, 4 Jul 2012 20:21:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2A4C5A0AC4 for ; Wed, 4 Jul 2012 13:21:10 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-we0-f177.google.com (mail-we0-f177.google.com [74.125.82.177]) by gabe.freedesktop.org (Postfix) with ESMTP id C1A8C9E989 for ; Wed, 4 Jul 2012 13:18:55 -0700 (PDT) Received: by mail-we0-f177.google.com with SMTP id b13so2863517wer.36 for ; Wed, 04 Jul 2012 13:18:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=x1BBm6YWaYd9Wu+eUqc4y5SELfmndgee+f0z1TxIAFo=; b=lY4UlM5EHWJHfBqFduEGA1nCHx3qMfRduPNFHqF3VePIa3w2mTZ6KoKE/07lDFp9o2 8OyW/NrJgxuez6ApiE5IkHOJL2jWzEy+nnW/4MrIwgSjuxPAXRAkh/aLifLe0W0vsH6S zm98aD/fBrrMD/esqsJiEevN7C8fngyFAquRU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=x1BBm6YWaYd9Wu+eUqc4y5SELfmndgee+f0z1TxIAFo=; b=nLdHkhAFrC1l7Va7FImC3yol636naaPewcW1f4J5ZLT9OUJiDT2VKDRbcLyFYubvVp 4BKUbh9lWG6gUJjnhsK+9YL+XorPp8tU4K6lqqbPUaTATpQfBXkn8770zEkeCrdpVEkl 0jhPkEgYLYOMBQxNA8Hpq6c4kgBMk16gH9bNMtAK3bY8cKZ/Ezdsuv2OOCievLnko8xg gbKYTFkfTR/h+FlkWupc0ccLHPtxEK+oYWcRy83fts5E15yFMQtCnHs1Q6vue1MBW12l HZA6H0G3820E90mNoVwBuW8iLS+9sqFB9H6cpDZN68ki1GgFwBRQpPptM5uD8VRZIfBN g/qg== Received: by 10.180.107.103 with SMTP id hb7mr36359516wib.3.1341433135460; Wed, 04 Jul 2012 13:18:55 -0700 (PDT) Received: from aaron.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPS id bg10sm69602224wib.9.2012.07.04.13.18.54 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 04 Jul 2012 13:18:54 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Date: Wed, 4 Jul 2012 22:18:41 +0200 Message-Id: <1341433123-23055-4-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.10 In-Reply-To: <1341433123-23055-1-git-send-email-daniel.vetter@ffwll.ch> References: <1341433123-23055-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQlmCQXPcTzuc0Eb9Mvjt8rONRcYFZmdhykCsg0i++Anc+w1AnBVHGgNcl0EjMc7ZsvrLwfO Cc: Daniel Vetter Subject: [Intel-gfx] [PATCH 3/5] drm/i915: don't hang userspace when the gpu reset is stuck X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org With the gpu reset no longer using a trylock we've increased the chances of userspace getting stuck quite a bit. To make that (hopefully) rare case more paletable time out when waiting for the gpu reset code to complete and signal this little issue to the caller by returning -EIO. This should help userspace to somewhat gracefully fall back and hopefully allow the user to grab some logs and reboot the machine (instead of staring at a frozen X screen in agony). Suggested by Chris Wilson because I've been stubborn about allowing the gpu reset code no to fail, ever (by removing the trylock). Signed-Off-by: Daniel Vetter --- drivers/gpu/drm/i915/i915_gem.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index af6a510..7d28555 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -96,9 +96,18 @@ i915_gem_wait_for_error(struct drm_device *dev) if (!atomic_read(&dev_priv->mm.wedged)) return 0; - ret = wait_for_completion_interruptible(x); - if (ret) + /* + * Only wait 10 seconds for the gpu reset to complete to avoid hanging + * userspace. If it takes that long something really bad is going on and + * we should simply try to bail out and fail as gracefully as possible. + */ + ret = wait_for_completion_interruptible_timeout(x, 10*HZ); + if (ret == 0) { + DRM_ERROR("Timed out waiting for the gpu reset to complete\n"); + return -EIO; + } else if (ret < 0) { return ret; + } if (atomic_read(&dev_priv->mm.wedged)) { /* GPU is hung, bump the completion count to account for