From patchwork Wed Oct 16 03:24:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Brost X-Patchwork-Id: 13837640 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 14F1DD20691 for ; Wed, 16 Oct 2024 03:24:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6363B10E002; Wed, 16 Oct 2024 03:24:58 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="KdfRpSqZ"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5EE0C10E002; Wed, 16 Oct 2024 03:24:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1729049097; x=1760585097; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=k9XOMvVCTO4ugVT5Csfzn7wndSqY1tSFw5PifJYE3co=; b=KdfRpSqZrjL0YJOE/ba93ouGog/sVCOFtL8x7hbpIGQqKWyMM8mKwM0J Neow7fVW2FQpPvE4aCp6ACP7ZuGjc+lRWZ9LEt97p5xgavNhSP2voU/7j rKoBS3ssEsMLa7uyykOoNIz3TKTMkz8hTxbYTNm6/7gAV/NUkip5RORKq AMXcvkjuyE1j2fKuogQPIl21mbhMlW7hz3vMLCelUDKU0c+XQ02cCJRek Sml6ZYW0unuASqmzLlmTv+WIh0sp3RdcPfYX1rSuGh43FKUwZ8uMzsqRM fHg3+dYyrEhC2f6GIlsN3Q7hOkkba3gGAmb/QxCXxqdQ0X1mC8ILrycKN g==; X-CSE-ConnectionGUID: Ry4UFKgzSxKL1osNB42AtA== X-CSE-MsgGUID: ZsYvIGNyS6Wi2cK9I3Rgrw== X-IronPort-AV: E=McAfee;i="6700,10204,11225"; a="39056329" X-IronPort-AV: E=Sophos;i="6.11,206,1725346800"; d="scan'208";a="39056329" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 20:24:57 -0700 X-CSE-ConnectionGUID: sH4Y8IuaRiKTKdrrPxG52w== X-CSE-MsgGUID: k+QwseXoR8Cv+oVwz2ttKw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,206,1725346800"; d="scan'208";a="78930250" Received: from lstrano-desk.jf.intel.com ([10.54.39.91]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Oct 2024 20:24:56 -0700 From: Matthew Brost To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: apopple@nvidia.com, airlied@gmail.com, christian.koenig@amd.com, thomas.hellstrom@linux.intel.com, simona.vetter@ffwll.ch, felix.kuehling@amd.com, dakr@kernel.org Subject: [PATCH v2 01/29] drm/xe: Retry BO allocation Date: Tue, 15 Oct 2024 20:24:50 -0700 Message-Id: <20241016032518.539495-2-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241016032518.539495-1-matthew.brost@intel.com> References: <20241016032518.539495-1-matthew.brost@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" TTM doesn't support fair eviction via WW locking, this mitigated in by using retry loops in exec and preempt rebind worker. Extend this retry loop to BO allocation. Once TTM supports fair eviction this patch can be reverted. Signed-off-by: Matthew Brost --- drivers/gpu/drm/xe/xe_bo.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c index 5b232f2951b1..a02d63e322ae 100644 --- a/drivers/gpu/drm/xe/xe_bo.c +++ b/drivers/gpu/drm/xe/xe_bo.c @@ -2011,6 +2011,7 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data, struct xe_file *xef = to_xe_file(file); struct drm_xe_gem_create *args = data; struct xe_vm *vm = NULL; + ktime_t end = 0; struct xe_bo *bo; unsigned int bo_flags; u32 handle; @@ -2083,11 +2084,14 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data, vm = xe_vm_lookup(xef, args->vm_id); if (XE_IOCTL_DBG(xe, !vm)) return -ENOENT; + } + +retry: + if (vm) { err = xe_vm_lock(vm, true); if (err) goto out_vm; } - bo = xe_bo_create_user(xe, NULL, vm, args->size, args->cpu_caching, bo_flags); @@ -2096,6 +2100,8 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data, if (IS_ERR(bo)) { err = PTR_ERR(bo); + if (xe_vm_validate_should_retry(NULL, err, &end)) + goto retry; goto out_vm; }