From patchwork Fri Dec 27 11:11:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: apoorva.singh@intel.com X-Patchwork-Id: 13921684 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 462A7E7718B for ; Fri, 27 Dec 2024 10:57:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B049710E061; Fri, 27 Dec 2024 10:57:52 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="g6usMb3q"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7BA6010E061 for ; Fri, 27 Dec 2024 10:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1735297072; x=1766833072; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=L8JGnghTE8fFYdnBHgNTfT3fy/KcTvtTvBTqxMcOpZ4=; b=g6usMb3qLS7WWnwaS1PrVMP7I85LKUeiCIcVGk66GxlvISO1+AW/QZrn ThJ6nxtlpxCr1XR0IZRLGO4tNU0jDsKcV5i9FWjqk6ZmwJAlgrL30FWsm tXIy611uG1EFBurIy4f6WrnxeYLtQK3/U5CbjtiZUnIQVzX2b0i8mGTJP jXcpcb8Xlu/MRiiJ6xX8dGAifPCB4dAn5rFtup4bYWblVkBZQxVs/r6x6 6jdyjSvWVJGWgNjd49i7UvoFYinrCvXBNUPpTXVCQQJG/jyEe/QZYbq6D /vmmr0ooNc5jMy8oRu8apWcdhUWSZjTrWac+m5Rf79Lpaf96d2YLOGPeb Q==; X-CSE-ConnectionGUID: D60hxNchSxGaUsXrkhz0eQ== X-CSE-MsgGUID: xiGWCQARSxCZw29HZe9ZJg== X-IronPort-AV: E=McAfee;i="6700,10204,11298"; a="39479065" X-IronPort-AV: E=Sophos;i="6.12,269,1728975600"; d="scan'208";a="39479065" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Dec 2024 02:57:52 -0800 X-CSE-ConnectionGUID: bZw4UxbrQX2vHQ6xWsn4ew== X-CSE-MsgGUID: huOMQmZpSzeCUHymEtLbBg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="100972588" Received: from singhapo-super-server.iind.intel.com ([10.145.169.90]) by orviesa008.jf.intel.com with ESMTP; 27 Dec 2024 02:57:49 -0800 From: apoorva.singh@intel.com To: intel-gfx@lists.freedesktop.org Cc: chris.p.wilson@linux.intel.com, Apoorva Singh Subject: [PATCH] drm/i915/gt: Add GEM_BUG_ON to ensure at least one engine supports migration Date: Fri, 27 Dec 2024 16:41:28 +0530 Message-Id: <20241227111128.1546618-1-apoorva.singh@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Apoorva Singh Ensure GEM_BUG_ON verifies at least one engine supports migration. Additionally, it prevents passing an uninitialized variable to intel_context_create(). Cc: Chris Wilson Signed-off-by: Apoorva Singh --- drivers/gpu/drm/i915/gt/intel_migrate.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/i915/gt/intel_migrate.c b/drivers/gpu/drm/i915/gt/intel_migrate.c index 6f7af4077135..528a7cba3623 100644 --- a/drivers/gpu/drm/i915/gt/intel_migrate.c +++ b/drivers/gpu/drm/i915/gt/intel_migrate.c @@ -296,6 +296,9 @@ static struct intel_context *__migrate_engines(struct intel_gt *gt) engines[count++] = engine; } + /* At least one engine must support migration! */ + GEM_BUG_ON(!count); + return intel_context_create(engines[random_index(count)]); }