Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp228458rwl; Wed, 29 Mar 2023 00:29:43 -0700 (PDT) X-Google-Smtp-Source: AKy350b2anLtA45QfMMyKQWvvRtzhUyUKaCOd//rNWgoeX0yl/Cv58z+pReq8IBD2Wza0gmQdXn9 X-Received: by 2002:a05:6402:d7:b0:501:c4e3:9914 with SMTP id i23-20020a05640200d700b00501c4e39914mr16803790edu.33.1680074983092; Wed, 29 Mar 2023 00:29:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680074983; cv=none; d=google.com; s=arc-20160816; b=Ny2xJc+2aAfckGzyDk/a3KcLH0F1Ph9+F5f7trdQV3rDbHFhaARvwWGFXvRmljDhAv NTnQeRPkZxcfqF1YPrGsKSJyz6JZSryyNN+VOoPRw2GPeiHboCKjIeFzSYChm0CPIFmX Nj094FSMfj3xRd08U6KYWRxDKwSe6RneLWMOU2RO1Oh3uOxCC1uI3AkyLfk1wsA0bmdQ JphcLdRZ2gebCEW4yv5Eo2ahjz3yHvMHw0aO7uDQmgAe72gCQbIFHC6BwAoFgX8I5WHM 8bi1XdKWO6RqfgmFi61s75/FQv/Y68N5nbhqy1l3so3CITzAj37wyj+llS8WbWaw6W34 EuEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=vujjWSFfrEVLUx7SXCvop7jyoOBLiPyxkHQMpSOS8hI=; b=zWXM/MCCakSmgpvuNEqnCIGWNuXslr6Gwm2p2Hrnbgir96qjyp/BFjwXeTf1AhA8H+ 7NNCsqEk9joMDLF5x/lLEPQwSNq1C0jopk0TDUXz0sqPEkJX0CuyCL9rEhjPFB7lNOQM 3umWW0Fbb60PThk6W6dJPFah8Qh2lL8gFLtp0X1gGjwXiTUt02iOOdBjFLpOPeLfaxdS y6+bAcEQSyHVxLoCElFIYNhA6XjFJUncyxLX0YauHY588brWNPCEcogp3o9PX9dV39sq +Xhbm2FqUbZgui14SaVJQC3vz2SnNLBTqXHPU9Id8nmaojznK78VinO7iyh23QheWj/m Udog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="N/GYQa9k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j16-20020aa7c0d0000000b004c0c33b95c1si24218326edp.324.2023.03.29.00.29.18; Wed, 29 Mar 2023 00:29:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="N/GYQa9k"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230129AbjC2H2H (ORCPT + 99 others); Wed, 29 Mar 2023 03:28:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbjC2H1N (ORCPT ); Wed, 29 Mar 2023 03:27:13 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F7E549DE; Wed, 29 Mar 2023 00:25:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680074751; x=1711610751; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=LsmUDbnIlE4apXp83QZEhT9gpY1ZA5IO+nuheEoXvek=; b=N/GYQa9kTd/jAIBz5kRVGsdDmG07okHPEV97uUKE1+JLOFwj62n7iNDT X7xc5rJpePGneiOWjkbN2AJf9lDFOdfGk+96Icqv6bpM1xhm40mdqjlv9 waIODQvnoPP+GpXpGyu1trTq0Bb6j/P7qO0J/7Ighbqj7/TLUW+scpeTu P0OB/CaDQAnYAF0H7Yr7aFUzC2zUDEnboPixrEX1hpxgJxxdBqYlVCoXp b4zfkIENYOqCPljBYXMVJC0YQlpfISzF5dtCjeP8tPa5IccCQJABv7rEx QNWWn59J6OIpZi6z3KspX5uOusSV/+lqQfBPXQklqu8HOg1a2PuBFFJP8 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="368569835" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="368569835" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 00:25:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10663"; a="827773197" X-IronPort-AV: E=Sophos;i="5.98,300,1673942400"; d="scan'208";a="827773197" Received: from lab-ah.igk.intel.com ([10.102.138.202]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Mar 2023 00:24:59 -0700 From: Andrzej Hajda Date: Wed, 29 Mar 2023 09:24:19 +0200 Subject: [PATCH v6 8/8] drm/i915/gt: Hold a wakeref for the active VM MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230224-track_gt-v6-8-0dc8601fd02f@intel.com> References: <20230224-track_gt-v6-0-0dc8601fd02f@intel.com> In-Reply-To: <20230224-track_gt-v6-0-0dc8601fd02f@intel.com> To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter Cc: linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Chris Wilson , netdev@vger.kernel.org, Eric Dumazet , Jakub Kicinski , Dmitry Vyukov , "David S. Miller" , Andi Shyti , Andrzej Hajda X-Mailer: b4 0.11.1 X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Wilson There may be a disconnect between the GT used by the engine and the GT used for the VM, requiring us to hold a wakeref on both while the GPU is active with this request. Signed-off-by: Chris Wilson Signed-off-by: Andrzej Hajda --- drivers/gpu/drm/i915/gt/intel_context.h | 15 +++++++++++---- drivers/gpu/drm/i915/gt/intel_context_types.h | 2 ++ drivers/gpu/drm/i915/gt/intel_engine_pm.c | 4 ++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_context.h b/drivers/gpu/drm/i915/gt/intel_context.h index 0a8d553da3f439..582faa21181e58 100644 --- a/drivers/gpu/drm/i915/gt/intel_context.h +++ b/drivers/gpu/drm/i915/gt/intel_context.h @@ -14,6 +14,7 @@ #include "i915_drv.h" #include "intel_context_types.h" #include "intel_engine_types.h" +#include "intel_gt_pm.h" #include "intel_ring_types.h" #include "intel_timeline_types.h" #include "i915_trace.h" @@ -207,8 +208,11 @@ void intel_context_exit_engine(struct intel_context *ce); static inline void intel_context_enter(struct intel_context *ce) { lockdep_assert_held(&ce->timeline->mutex); - if (!ce->active_count++) - ce->ops->enter(ce); + if (ce->active_count++) + return; + + ce->ops->enter(ce); + ce->wakeref = intel_gt_pm_get(ce->vm->gt); } static inline void intel_context_mark_active(struct intel_context *ce) @@ -222,8 +226,11 @@ static inline void intel_context_exit(struct intel_context *ce) { lockdep_assert_held(&ce->timeline->mutex); GEM_BUG_ON(!ce->active_count); - if (!--ce->active_count) - ce->ops->exit(ce); + if (--ce->active_count) + return; + + intel_gt_pm_put_async(ce->vm->gt, ce->wakeref); + ce->ops->exit(ce); } static inline struct intel_context *intel_context_get(struct intel_context *ce) diff --git a/drivers/gpu/drm/i915/gt/intel_context_types.h b/drivers/gpu/drm/i915/gt/intel_context_types.h index e36670f2e6260b..5dc39a9d7a501c 100644 --- a/drivers/gpu/drm/i915/gt/intel_context_types.h +++ b/drivers/gpu/drm/i915/gt/intel_context_types.h @@ -17,6 +17,7 @@ #include "i915_utils.h" #include "intel_engine_types.h" #include "intel_sseu.h" +#include "intel_wakeref.h" #include "uc/intel_guc_fwif.h" @@ -110,6 +111,7 @@ struct intel_context { u32 ring_size; struct intel_ring *ring; struct intel_timeline *timeline; + intel_wakeref_t wakeref; unsigned long flags; #define CONTEXT_BARRIER_BIT 0 diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.c b/drivers/gpu/drm/i915/gt/intel_engine_pm.c index 7063dea2112943..c2d17c97bfe989 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_pm.c +++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.c @@ -114,6 +114,10 @@ __queue_and_release_pm(struct i915_request *rq, ENGINE_TRACE(engine, "parking\n"); + GEM_BUG_ON(rq->context->active_count != 1); + __intel_gt_pm_get(engine->gt); + rq->context->wakeref = intel_wakeref_track(&engine->gt->wakeref); + /* * We have to serialise all potential retirement paths with our * submission, as we don't want to underflow either the -- 2.34.1