From patchwork Wed Sep 14 22:04:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Roper X-Patchwork-Id: 12976576 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 43261ECAAD3 for ; Wed, 14 Sep 2022 22:05:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0CCBD10EA0F; Wed, 14 Sep 2022 22:04:46 +0000 (UTC) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 21B1510EA0E; Wed, 14 Sep 2022 22:04:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663193081; x=1694729081; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DeNnr9C26u2Vin05I4XJHX9ymoaMOzdoJW7jAwyYXBg=; b=dGIem6zMf4UmO7qCsijEYmTaxz1qN8l9sM1LZY5naN3ViHZNV1siJghf 7ThHg1TwpUbuC0aGBMIo40vb2V33PATt7/zycU83ubsnLqLsnRe2Juzco egc7yeyHqspeL8uU43/H3FXA2sZVQ1kbZsLhEHTEfbbNg2W55DMpnCjp6 KtFMLKxx9I1BaoErDLoNtQfXR8l4sWTJFKdsjBvIjAbVUtNEUEJfCf02y m8VxK02121fWlW5HKDt+mhjSfCNAnGGPiW+ISYemnL/9v9fS4FbIeDy2g HT4rBRRGHIt7G0one11U9Kq1PYgHtEdTyOOS7DcPV5Kf7+VfAqB2eBiiT A==; X-IronPort-AV: E=McAfee;i="6500,9779,10470"; a="278280793" X-IronPort-AV: E=Sophos;i="5.93,315,1654585200"; d="scan'208";a="278280793" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2022 15:04:40 -0700 X-IronPort-AV: E=Sophos;i="5.93,315,1654585200"; d="scan'208";a="647570924" Received: from mdroper-desk1.fm.intel.com ([10.1.27.134]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Sep 2022 15:04:40 -0700 From: Matt Roper To: intel-gfx@lists.freedesktop.org Date: Wed, 14 Sep 2022 15:04:24 -0700 Message-Id: <20220914220427.3091448-2-matthew.d.roper@intel.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220914220427.3091448-1-matthew.d.roper@intel.com> References: <20220914220427.3091448-1-matthew.d.roper@intel.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 1/4] drm/i915/gt: Cleanup partial engine discovery failures X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chris Wilson , dri-devel@lists.freedesktop.org, Chris Wilson Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Chris Wilson If we abort driver initialisation in the middle of gt/engine discovery, some engines will be fully setup and some not. Those incompletely setup engines only have 'engine->release == NULL' and so will leak any of the common objects allocated. Signed-off-by: Chris Wilson Cc: Janusz Krzysztofik Signed-off-by: Matt Roper --- drivers/gpu/drm/i915/gt/intel_engine_cs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c index 1f7188129cd1..bff12b4ec314 100644 --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c @@ -1196,6 +1196,12 @@ void intel_engine_destroy_pinned_context(struct intel_context *ce) intel_context_put(ce); } +static void destroy_pinned_context(struct intel_context *ce) +{ + if (ce) + intel_engine_destroy_pinned_context(ce); +} + static struct intel_context * create_kernel_context(struct intel_engine_cs *engine) { @@ -1274,8 +1280,13 @@ int intel_engines_init(struct intel_gt *gt) return err; err = setup(engine); - if (err) + if (err) { + intel_engine_cleanup_common(engine); return err; + } + + /* The backend should now be responsible for cleanup */ + GEM_BUG_ON(engine->release == NULL); err = engine_init_common(engine); if (err) @@ -1307,8 +1318,7 @@ void intel_engine_cleanup_common(struct intel_engine_cs *engine) if (engine->default_state) fput(engine->default_state); - if (engine->kernel_context) - intel_engine_destroy_pinned_context(engine->kernel_context); + destroy_pinned_context(engine->kernel_context); GEM_BUG_ON(!llist_empty(&engine->barrier_tasks)); cleanup_status_page(engine);