Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6195526rwl; Tue, 4 Apr 2023 09:05:07 -0700 (PDT) X-Google-Smtp-Source: AKy350ZYfgxTylGwZjjOY1g7UMpSTsftfXsYR1dTBU7YxbiZPZuBAzRFe3RL4aNyJ/n+grVWLJ61 X-Received: by 2002:a17:906:2a0b:b0:946:fa88:5901 with SMTP id j11-20020a1709062a0b00b00946fa885901mr6122eje.63.1680624307644; Tue, 04 Apr 2023 09:05:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680624307; cv=none; d=google.com; s=arc-20160816; b=BFpkrFvZfdIq8TCJQLT+2hNmPRsHF9nKT/ukiFLvT/0qNTl6yjG37DE3+Md+0R9LuX 86Wvm4ZYAgr9iCYiT8Osx+xcymgIAsoZP8kOopSmuXf4POMFqNs+6OB2q4X8aouCGp+B VS5XuIZ6hpPcrdy8mNaSaj+1LdEnHNkJxTlQqrHd3ZLTaHr9o6aqT4IFTt0FWah+uDRD lbsrDUXL6U+xFLiZpYj1uZF1EJd5pCjDfl29TuwiE9eiYc6WWAJ5poesBOxOUrVTVWkQ tDJDEtOVxKDO8Zmcn0ABez7bkNQPLQDF3RGx2B3rgNHkgtAIoPfNUStxkT/FmdLkVXTN D87Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jHQfTXe5DBw8StB9TuzgY/7NLIz5rSFRQJBW4MTuD4g=; b=QiBgQfvsQWMV1Zj8Fn3ayCZCbLJfsbCc7h5mpwjNfFOQIoaI8KZMm/m15UCVO6yGuk Hq9S0lTJR25646+lVC0ol+ccFRpr51kPSrMTSdpED6OomwtgqHPv7RL8I820HdKbEEUh QMYaCxzEBbj+QCg7FiuTjuDiV47Cw3/tBvqQ8yI7B+VpxGpsSYX0Wv7Keay9RSUnMItN CpdXj7UzwHuujnr1dJoq+F1KOCbVkeW3zRoqBQ7vOj4q9zeSR6D2V7R9YTr3BOnqVch9 mmQtg9CaAn1KuaOcr0vhkZyyi/Ikf2G6AbY9YnpUWNSPWgLMjFN4Qtyr/Dpzw7VdN5Zs iquQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q5wZ1s0u; 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 rl3-20020a170907216300b00946f79be789si2308478ejb.985.2023.04.04.09.04.18; Tue, 04 Apr 2023 09:05:07 -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=Q5wZ1s0u; 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 S235223AbjDDQAu (ORCPT + 99 others); Tue, 4 Apr 2023 12:00:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235081AbjDDQAo (ORCPT ); Tue, 4 Apr 2023 12:00:44 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82B4440FD for ; Tue, 4 Apr 2023 09:00:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1680624042; x=1712160042; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=B2VCrvRDMzzWoBj/sY/dOe8TgaAA+UY1ACaoJ3AXUvM=; b=Q5wZ1s0uGdMt7Wig2ryzrnjOqY/FCu9URqIx0GKMfT2UnxuhICHGl8rv j6s//xVYm18YY8I8rj8c57bIBSW6KSmAeHZiXe4CRsqZL9vdB1q9TLggS T2WgBCdcF0IqYPoIf3NT9KckIPMCz0BfvVPAa1VqmJ150MLstj6uSHDd3 3GIrzhxM/kvC5EkzVZe/Jf04e1RBG6MxNYQFcad/lX36K57zLD35C7P2B P7CFF33S5pWS2MjBAUAutxmSXugV5xRm01FOyBIgSwjy5TzQU8o52QsrQ 5xYyu/Pa0idlV1tBDj21WbdG9GGfdtfT2bYkGBgsMq43yasylJErMRi87 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10670"; a="339716599" X-IronPort-AV: E=Sophos;i="5.98,318,1673942400"; d="scan'208";a="339716599" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2023 09:00:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10670"; a="755693328" X-IronPort-AV: E=Sophos;i="5.98,318,1673942400"; d="scan'208";a="755693328" Received: from vferra-mobl1.ger.corp.intel.com (HELO intel.com) ([10.252.53.196]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2023 09:00:37 -0700 Date: Tue, 4 Apr 2023 18:00:10 +0200 From: Andi Shyti To: Tvrtko Ursulin Cc: Andi Shyti , Andrzej Hajda , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Chris Wilson , Chris Wilson Subject: Re: [PATCH v2] drm/i915/gt: Hold a wakeref for the active VM Message-ID: References: <20230330-hold_wakeref_for_active_vm-v2-1-724d201499c2@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,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 Hi Tvrtko, > > > diff --git a/drivers/gpu/drm/i915/gt/intel_context.h b/drivers/gpu/drm/i915/gt/intel_context.h > > > index 0a8d553da3f439..48f888c3da083b 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); > > > + 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->ops->exit(ce); > > > > shouldn't these two be swapped? maybe I wasn't clear here... shouldn't it be ce->ops->exit(ce); intel_gt_pm_put_async(ce->vm->gt); Don't we need to hold the pm until exiting? > > > } > > > static inline struct intel_context *intel_context_get(struct intel_context *ce) > > > diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.c b/drivers/gpu/drm/i915/gt/intel_engine_pm.c > > > index e971b153fda976..ee531a5c142c77 100644 > > > --- a/drivers/gpu/drm/i915/gt/intel_engine_pm.c > > > +++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.c > > > @@ -114,6 +114,15 @@ __queue_and_release_pm(struct i915_request *rq, > > > ENGINE_TRACE(engine, "parking\n"); > > > + /* > > > + * Open coded one half of intel_context_enter, which we have to omit > > > + * here (see the large comment below) and because the other part must > > > + * not be called due constructing directly with __i915_request_create > > > + * which increments active count via intel_context_mark_active. > > > + */ > > > + GEM_BUG_ON(rq->context->active_count != 1); > > > + __intel_gt_pm_get(engine->gt); > > > > where is it's brother "put"? > > It's in request retire via intel_context_exit. Ie. request construction is > special here, while retirement is standard. Thank you! Andi