Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3202149pxb; Mon, 9 Nov 2020 05:29:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvoZPa6/MzyqbuHU74aOrjxB9cthtXNJo4oM23t94+JqFl+COhQDOD53y4A2ywtcYvQQ1J X-Received: by 2002:a05:6402:8cc:: with SMTP id d12mr15480634edz.134.1604928584110; Mon, 09 Nov 2020 05:29:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604928584; cv=none; d=google.com; s=arc-20160816; b=KQ0FY6fuYoZ7/yoT/zSAK/j1GmvyhtOkt6FO+NzQrMs26y/S2KxF4UTjzkdIRSplqM AZDtjOM2/qjRG7LwNqTD6xVcNBMTz5Yo2mxZexzn62No7a+nXpNSxB6hyKj5uBt6NMUX qk91qL1xd8UiU8EdFQ9XCj5uarYaC7iViDjBnkk9Ov+pe4FL27U1CV1QAO3MxlCmLQ1c LuuwAM7iwKiOXL5xF/BdBEGpq89eiuNI6x1sQmY2dDMHFokcjq4STIbSs8We6ynu4hlC DDpj0QgaVY9RvZYvln9cS9cyX5TiO/57mh6Oo4Sfzv6B2Nt5k/0ds8UV1b9RWM4DjqnO rdpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=fAY75jfDgeXBl8Kiv+K2hG34hCjhduSKgK14X2F4ExE=; b=nh4B/cdYxoNcsviRKwMNPmZvV3bF1YFdwcw+fSG8hXjXbHecaBmnllzw5XkqotJzwI JE/7fw5AabsBRdYI6/gTlmadp5ILqQSYKbpG79YYC4tbzx9ef+8Ec6yM3S71N3qdNrFG MMNuK0pqZjWE4lJFrarinEKBU/zBcXlCGGGHgyi5IVRcPtRc6WvnI5hkkPvhD8vNA28v 4WILSNE0H6CdrDmW77txLFUmJjJNuqizmUzfnJH7mscbcO+BEIPUl1rfHi0lKD/nGm3K zA/Be2jGmYuF2dwk8r7klRGa8GmS6UEqeWNVdxPx1KPwEYIChWVyIeWLbmXIppB5dTZ/ KCQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T+UtMm0e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 93si2443297edm.34.2020.11.09.05.29.18; Mon, 09 Nov 2020 05:29:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T+UtMm0e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732798AbgKINRG (ORCPT + 99 others); Mon, 9 Nov 2020 08:17:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:44176 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387550AbgKINRF (ORCPT ); Mon, 9 Nov 2020 08:17:05 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7FA5C206D8; Mon, 9 Nov 2020 13:17:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927824; bh=XaVMIKk/Fu7nd4j8T4EkH/lhmw7SGKRwAW1MZpKBHpY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T+UtMm0eRmiUCfQZd0K05oO+3wAljSsIwmF0uNHeRkEysSxP8KWcVhUaF9x7DWv+h CdBCyh2DXE+AIiLJ3/ZHlxUyqM2fyVTJzfwPYPjFQKnZ08U2pNQP2u6/kKV8bR6Sep Fol/w52sWYa2HFRGucDjWk71ZM+9efdh9Tw0G/ks= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , Joonas Lahtinen , Tvrtko Ursulin , Rodrigo Vivi Subject: [PATCH 5.9 008/133] drm/i915: Cancel outstanding work after disabling heartbeats on an engine Date: Mon, 9 Nov 2020 13:54:30 +0100 Message-Id: <20201109125031.119093258@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125030.706496283@linuxfoundation.org> References: <20201109125030.706496283@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Wilson commit 7d442ea7c504adcc9798b07cd8f6a0d235fca2da upstream. We only allow persistent requests to remain on the GPU past the closure of their containing context (and process) so long as they are continuously checked for hangs or allow other requests to preempt them, as we need to ensure forward progress of the system. If we allow persistent contexts to remain on the system after the the hangcheck mechanism is disabled, the system may grind to a halt. On disabling the mechanism, we sent a pulse along the engine to remove all executing contexts from the engine which would check for hung contexts -- but we did not prevent those contexts from being resubmitted if they survived the final hangcheck. Fixes: 9a40bddd47ca ("drm/i915/gt: Expose heartbeat interval via sysfs") Testcase: igt/gem_ctx_persistence/heartbeat-stop Signed-off-by: Chris Wilson Cc: Joonas Lahtinen Cc: # v5.7+ Reviewed-by: Tvrtko Ursulin Acked-by: Joonas Lahtinen Link: https://patchwork.freedesktop.org/patch/msgid/20200928221510.26044-1-chris@chris-wilson.co.uk (cherry picked from commit 7a991cd3e3da9a56d5616b62d425db000a3242f2) Signed-off-by: Rodrigo Vivi Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/gt/intel_engine.h | 9 +++++++++ drivers/gpu/drm/i915/i915_request.c | 5 +++++ 2 files changed, 14 insertions(+) --- a/drivers/gpu/drm/i915/gt/intel_engine.h +++ b/drivers/gpu/drm/i915/gt/intel_engine.h @@ -357,4 +357,13 @@ intel_engine_has_preempt_reset(const str return intel_engine_has_preemption(engine); } +static inline bool +intel_engine_has_heartbeat(const struct intel_engine_cs *engine) +{ + if (!IS_ACTIVE(CONFIG_DRM_I915_HEARTBEAT_INTERVAL)) + return false; + + return READ_ONCE(engine->props.heartbeat_interval_ms); +} + #endif /* _INTEL_RINGBUFFER_H_ */ --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c @@ -549,8 +549,13 @@ bool __i915_request_submit(struct i915_r if (i915_request_completed(request)) goto xfer; + if (unlikely(intel_context_is_closed(request->context) && + !intel_engine_has_heartbeat(engine))) + intel_context_set_banned(request->context); + if (unlikely(intel_context_is_banned(request->context))) i915_request_set_error_once(request, -EIO); + if (unlikely(fatal_error(request->fence.error))) __i915_request_skip(request);