From patchwork Thu Feb 23 19:14:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Winiarski?= X-Patchwork-Id: 9588853 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 092B160578 for ; Thu, 23 Feb 2017 19:14:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECBC228739 for ; Thu, 23 Feb 2017 19:14:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E11422879A; Thu, 23 Feb 2017 19:14:39 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 76D6228739 for ; Thu, 23 Feb 2017 19:14:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 895B66EAB8; Thu, 23 Feb 2017 19:14:38 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6CC336EAB8 for ; Thu, 23 Feb 2017 19:14:37 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Feb 2017 11:14:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.35,198,1484035200"; d="scan'208"; a="1114783361" Received: from irsmsx102.ger.corp.intel.com ([163.33.3.155]) by fmsmga001.fm.intel.com with ESMTP; 23 Feb 2017 11:14:35 -0800 Received: from mwiniars-main.igk.intel.com (172.28.171.152) by IRSMSX102.ger.corp.intel.com (163.33.3.155) with Microsoft SMTP Server id 14.3.248.2; Thu, 23 Feb 2017 19:14:35 +0000 From: =?UTF-8?q?Micha=C5=82=20Winiarski?= To: Date: Thu, 23 Feb 2017 20:14:15 +0100 Message-ID: <20170223191421.4502-1-michal.winiarski@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170223190833.2888-1-michal.winiarski@intel.com> References: <20170223190833.2888-1-michal.winiarski@intel.com> MIME-Version: 1.0 X-Originating-IP: [172.28.171.152] Subject: [Intel-gfx] [RFC 05/11] drm/i915/preempt: Handle preemption event in guc tasklet 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-Virus-Scanned: ClamAV using ClamSMTP We need to avoid sending new work if the preemption is in progress. Once it finished, we need to identify and unsubmit the preempted workload, submit new workload (potentially the one responsible for preemption) and resubmit the preempted workload. Signed-off-by: MichaƂ Winiarski --- drivers/gpu/drm/i915/i915_gem_request.h | 2 + drivers/gpu/drm/i915/i915_guc_submission.c | 64 ++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem_request.h b/drivers/gpu/drm/i915/i915_gem_request.h index 5f73d8c..a78408dd 100644 --- a/drivers/gpu/drm/i915/i915_gem_request.h +++ b/drivers/gpu/drm/i915/i915_gem_request.h @@ -170,6 +170,8 @@ struct drm_i915_gem_request { /** Time at which this request was emitted, in jiffies. */ unsigned long emitted_jiffies; + struct list_head resubmit_link; + /** engine->request_list entry for this request */ struct list_head link; diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c index 6d9431d..6c64ce1 100644 --- a/drivers/gpu/drm/i915/i915_guc_submission.c +++ b/drivers/gpu/drm/i915/i915_guc_submission.c @@ -580,6 +580,10 @@ static bool i915_guc_dequeue(struct intel_engine_cs *engine) bool submit = false; spin_lock_irqsave(&engine->timeline->lock, flags); + + if (engine->preempt_requested) + goto out; + rb = engine->execlist_first; while (rb) { struct drm_i915_gem_request *cursor = @@ -607,17 +611,71 @@ static bool i915_guc_dequeue(struct intel_engine_cs *engine) nested_enable_signaling(last); engine->execlist_first = rb; } +out: spin_unlock_irqrestore(&engine->timeline->lock, flags); return submit; } +static void unsubmit_inflight_requests(struct intel_engine_cs *engine, + struct list_head *resubmit) +{ + struct drm_i915_gem_request *rq, *prev; + + assert_spin_locked(&engine->timeline->lock); + + list_for_each_entry_safe_reverse(rq, prev, + &engine->timeline->requests, link) { + if (!i915_gem_request_completed(rq)) { + i915_gem_request_get(rq); + __i915_gem_request_unsubmit(rq); + list_add(&rq->resubmit_link, resubmit); + } + } +} + +static void resubmit_inflight_requests(struct intel_engine_cs *engine, + struct list_head *resubmit) +{ + struct drm_i915_gem_request *rq, *prev; + + assert_spin_locked(&engine->timeline->lock); + + list_for_each_entry_safe(rq, prev, resubmit, resubmit_link) { + list_del(&rq->resubmit_link); + __i915_gem_request_submit(rq); + i915_gem_request_put(rq); + } +} + static void i915_guc_irq_handler(unsigned long data) { struct intel_engine_cs *engine = (struct intel_engine_cs *)data; struct execlist_port *port = engine->execlist_port; struct drm_i915_gem_request *rq; + unsigned long flags; bool submit; + LIST_HEAD(resubmit); + + spin_lock_irqsave(&engine->timeline->lock, flags); + if (engine->preempt_requested && + intel_engine_is_preempt_finished(engine)) { + unsubmit_inflight_requests(engine, &resubmit); + engine->preempt_requested = false; + intel_write_status_page(engine, I915_GEM_HWS_PREEMPT_INDEX, 0); + + rq = port[0].request; + while(rq && i915_gem_request_completed(rq)) { + i915_gem_request_put(rq); + if (port != engine->execlist_port) + break; + port++; + } + port = engine->execlist_port; + port[0].request = NULL; + port[1].request = NULL; + } + spin_unlock_irqrestore(&engine->timeline->lock, flags); do { rq = port[0].request; @@ -632,6 +690,12 @@ static void i915_guc_irq_handler(unsigned long data) if (!port[1].request) submit = i915_guc_dequeue(engine); } while (submit); + + if (!list_empty(&resubmit)) { + spin_lock_irqsave(&engine->timeline->lock, flags); + resubmit_inflight_requests(engine, &resubmit); + spin_unlock_irqrestore(&engine->timeline->lock, flags); + } } /*