From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60FCD3F4DC7 for ; Mon, 13 Jul 2026 11:59:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783943964; cv=none; b=YBl5IrPzOn/DpX8pdtV3kWQTk3aSjpjV5YWIuDzX6EEpGIFedw9jfRcFuAY5XQovMj4p2E0TRvRHndcHOcNn1HbGWfkMzfnFt89X89iM19Fqm3z3el7y4LjPjFuaCONSXXmRoMsRcyh8HyLc8EJGopmIW96ycJefF+GIWyDvspc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783943964; c=relaxed/simple; bh=PgDGdaaeyCwoG8D4U3B9sdB9c36Rvxkiwqgo8Jml1n0=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References: Content-Type:MIME-Version; b=JKpiM8EM1BaNEK36lO2R9vm+rO2GQ5xBk0D9VcRGCPD4FezTWjtgUhPxK+ObsmCFihyuE34kpGrfzmlh1uivsmWs2Ax8UD+HQ6eGrdqerSbCX6gAdJtnZJ+qg9SE2SgbAAh3qPJMMVaCIz2EpwgWtKE0RkZ9NPRpt42eVpwxmJk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SQ6Oafh/; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SQ6Oafh/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1783943963; x=1815479963; h=message-id:subject:from:to:date:in-reply-to:references: content-transfer-encoding:mime-version; bh=PgDGdaaeyCwoG8D4U3B9sdB9c36Rvxkiwqgo8Jml1n0=; b=SQ6Oafh/KNxQF42zEF2I94Jj+VRU02uujLwe3NiP8qmC6WquIxjmZ9Dg W40vtOSS95LZ+4JqxfGVAlz2hohsr5DNavjNEsk6i6qpdPBV0IYkYOCV0 GCuj3v9FlgTsCQagzabaqw3sLDOTZfRNQVeYbhBijRYJU71J6l/a50bLc bKzlwRaBEAYd0k4/Lu+Lfe74/nOcMKPZQ9on13I+S5ajhUrI8a8W1DxsI rBQVF3UiEB9LmJT15OHviNjfxOtnObQflN4eVnaRKg6FlXW6CoUytvfVO Jr0Q0143Oj6lYNhBUfTsZEaoW/fWPPbNlLkz4KnChROMEW+9p+8k3cEzg w==; X-CSE-ConnectionGUID: StAujCJtT2yEODZbebtMFw== X-CSE-MsgGUID: o3tN0vS+T5e6AIKjd/71DQ== X-IronPort-AV: E=McAfee;i="6800,10657,11841"; a="110093151" X-IronPort-AV: E=Sophos;i="6.25,154,1779174000"; d="scan'208";a="110093151" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2026 04:59:23 -0700 X-CSE-ConnectionGUID: EdEs7uRIQRK4Y6eKspC4zA== X-CSE-MsgGUID: aWF+8JjORm2nS6zE8oKajA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.25,154,1779174000"; d="scan'208";a="254399571" Received: from mkosciow-mobl1.ger.corp.intel.com (HELO [10.245.245.123]) ([10.245.245.123]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2026 04:59:20 -0700 Message-ID: Subject: Re: [PATCH 11/12] drm/ttm: support using drm_exec during eviction v4 From: Thomas =?ISO-8859-1?Q?Hellstr=F6m?= To: christian.koenig@amd.com, dakr@kernel.org, ecourtney@nvidia.com, simona@ffwll.ch, matthew.brost@intel.com, nat@pixelcluster.dev, airlied@gmail.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Date: Mon, 13 Jul 2026 13:59:17 +0200 In-Reply-To: <20260710190752.2355-12-christian.koenig@amd.com> References: <20260710190752.2355-1-christian.koenig@amd.com> <20260710190752.2355-12-christian.koenig@amd.com> Organization: Intel Sweden AB, Registration Number: 556189-6027 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.58.3 (3.58.3-1.fc43) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Fri, 2026-07-10 at 20:52 +0200, Christian K=C3=B6nig wrote: > Allow specifying a drm_exec object in TTMs operation context which is > used to lock objects during eviction. >=20 > This allows to handle deadlocks much more gracefully and with that > avoid returning -ENOMEM on heavily contended domains. >=20 > v2: rebased on top of Thomas work > v3: rebased again > v4: adjust to dma_resv changes >=20 > Signed-off-by: Christian K=C3=B6nig Same thing here. Use a ww context at the dma-buf level. Thanks, Thomas > --- > =C2=A0drivers/gpu/drm/ttm/ttm_bo_util.c | 12 ++++++++---- > =C2=A0include/drm/ttm/ttm_bo.h=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 |=C2=A0 5 +++++ > =C2=A02 files changed, 13 insertions(+), 4 deletions(-) >=20 > diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c > b/drivers/gpu/drm/ttm/ttm_bo_util.c > index 1bdd69643c313..570640ae79d84 100644 > --- a/drivers/gpu/drm/ttm/ttm_bo_util.c > +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c > @@ -38,6 +38,7 @@ > =C2=A0#include > =C2=A0 > =C2=A0#include > +#include > =C2=A0 > =C2=A0struct ttm_transfer_obj { > =C2=A0 struct ttm_buffer_object base; > @@ -839,7 +840,9 @@ static int ttm_lru_walk_ticketlock(struct > ttm_bo_lru_cursor *curs, > =C2=A0 struct ttm_lru_walk_arg *arg =3D curs->arg; > =C2=A0 int ret; > =C2=A0 > - if (arg->ctx->interruptible) > + if (arg->ctx->exec) > + ret =3D drm_exec_lock_resv(arg->ctx->exec, resv); > + else if (arg->ctx->interruptible) > =C2=A0 ret =3D dma_resv_lock_interruptible(resv, arg- > >ticket); > =C2=A0 else > =C2=A0 ret =3D dma_resv_lock(resv, arg->ticket); > @@ -853,7 +856,8 @@ static int ttm_lru_walk_ticketlock(struct > ttm_bo_lru_cursor *curs, > =C2=A0 * trylocking for this walk. > =C2=A0 */ > =C2=A0 arg->ticket =3D NULL; > - } else if (ret =3D=3D -EDEADLK) { > + > + } else if (!arg->ctx->exec && ret =3D=3D -EDEADLK) { > =C2=A0 /* Caller needs to exit the ww transaction. */ > =C2=A0 ret =3D -ENOSPC; > =C2=A0 } > @@ -993,8 +997,8 @@ __ttm_bo_lru_cursor_iter(struct ttm_bo_lru_cursor > *curs, bool first) > =C2=A0 if (!ttm_lru_walk_trylock(curs, res->bo->base.resv)) > { > =C2=A0 struct dma_resv *resv; > =C2=A0 > - if (!arg->ticket || arg->ctx->no_wait_gpu || > - =C2=A0=C2=A0=C2=A0 arg->trylock_only) { > + if ((!arg->ticket || arg->ctx->no_wait_gpu > || > + =C2=A0=C2=A0=C2=A0=C2=A0 arg->trylock_only) && !arg->ctx->exec) > { > =C2=A0 spin_unlock(lru_lock); > =C2=A0 continue; > =C2=A0 } > diff --git a/include/drm/ttm/ttm_bo.h b/include/drm/ttm/ttm_bo.h > index e1221e3be7bda..0ffa84a5caa65 100644 > --- a/include/drm/ttm/ttm_bo.h > +++ b/include/drm/ttm/ttm_bo.h > @@ -186,6 +186,11 @@ struct ttm_operation_ctx { > =C2=A0 * @bytes_moved: Statistics on how many bytes have been > moved. > =C2=A0 */ > =C2=A0 uint64_t bytes_moved; > + /* > + * @exec: optional drm_exec object to use for locking and > contention > + * handling > + */ > + struct drm_exec *exec; > =C2=A0}; > =C2=A0 > =C2=A0struct ttm_lru_walk;