From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) (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 9FDC537BE6A for ; Fri, 8 May 2026 16:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778256588; cv=none; b=VnRhnmRS3Bfq9qpiikL5cCI6jlJjcXoDsqxaB0oeVSywe8cZ1B/VK7cZEVoc0yFYBZDet2A56i7hoDdugI8C6aFOORuS3myAESxJKN284t3iJaGWLIsjUu/Z+enUTx0ysMaZvcNn0ydvwKYMFJDeRdJCIv1LKlUN2k4qOu+DhW0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778256588; c=relaxed/simple; bh=Pw89MZSsx4bacdYuTC5zAh+6l0iElYL9UiZ16rDQxZc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=HpnerJS6TX/s7gJbF2GTZNdqFrCTb0g2pGwdEDj5SNp5HOqlx4QF4Mp8y590yDJpuk+76QimE5D4qtgFtsZp6GJ8ZUs973lg8mEqp1+HS0EXiR5EzJS8hJGMCPdsjEijEEIbMG7lZDS9vwLOAaaTATm4J4dwV/sqnCpS3Qyc6dA= 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=Zu0DqkFn; arc=none smtp.client-ip=198.175.65.11 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="Zu0DqkFn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1778256585; x=1809792585; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Pw89MZSsx4bacdYuTC5zAh+6l0iElYL9UiZ16rDQxZc=; b=Zu0DqkFn2ngPTaXUfFbO031gny7t/GyqeM9d7No19AVW5lZsd6YsU8ar Vo/PLPAGQjcPcbKGLmCsTRwhGOCG/DIdqKlvR7UqcmsWespBfJqHdL3Ki ehaI/JB6JFcJso25ho54kCxhof4dD9kJ7C7lVLt/jAux7mxzxFvyXiB3O sCZwCbfToIF3ggtQxm7jodpkIHT2O2uB4SCKyyhOx6WJZ2EbyWRm1jCe/ PZ+sLski0nGOJ2Z0ctk9jmnLe4bdOa1R/VuGHklT03D8mYnNASVXaBlRu nSS87FHMk9wr9RK1bDc9RkwOBP8TorJtfvww9jjc7QoKIoR7/IDgQxuMA A==; X-CSE-ConnectionGUID: L1C8aWEUT+6znvbnRO0xGg== X-CSE-MsgGUID: h9tY5fM1SpmfnllBAMi0Hg== X-IronPort-AV: E=McAfee;i="6800,10657,11780"; a="89539871" X-IronPort-AV: E=Sophos;i="6.23,223,1770624000"; d="scan'208";a="89539871" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2026 09:09:45 -0700 X-CSE-ConnectionGUID: FJAc6G/QQyy1fPCAC7AGUg== X-CSE-MsgGUID: aH38HiWrQ4C3m41TPr42Yg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,223,1770624000"; d="scan'208";a="274916674" Received: from rvuia-mobl.ger.corp.intel.com (HELO fedora) ([10.245.244.34]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2026 09:09:43 -0700 From: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= To: intel-xe@lists.freedesktop.org Cc: =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Friedrich Vock , Maarten Lankhorst , Tejun Heo , Maxime Ripard , Christian Koenig , dri-devel@lists.freedesktop.org, stable@vger.kernel.org Subject: [PATCH] drm/ttm: Convert -EAGAIN from dmem_cgroup_try_charge to -ENOSPC Date: Fri, 8 May 2026 18:09:20 +0200 Message-ID: <20260508160920.230339-1-thomas.hellstrom@linux.intel.com> X-Mailer: git-send-email 2.54.0 Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dmem_cgroup_try_charge() returns -EAGAIN when the cgroup limit is hit and the charge fails. TTM has no concept of -EAGAIN from resource allocation; -ENOSPC is the canonical error meaning "no space, try eviction". Convert at the source in ttm_resource_alloc() so no caller needs to handle an unexpected error code, and clean up the now-redundant -EAGAIN check in ttm_bo_alloc_resource(). Without this, -EAGAIN escaping ttm_resource_alloc() during an eviction walk causes the walk to terminate early instead of continuing to the next candidate. Cc: Friedrich Vock Cc: Maarten Lankhorst Cc: Tejun Heo Cc: Maxime Ripard Cc: Christian Koenig Cc: dri-devel@lists.freedesktop.org Cc: # v6.14+ Fixes: 2b624a2c1865 ("drm/ttm: Handle cgroup based eviction in TTM") Assisted-by: GitHub_Copilot:claude-sonnet-4.6 Signed-off-by: Thomas Hellström --- drivers/gpu/drm/ttm/ttm_bo.c | 2 +- drivers/gpu/drm/ttm/ttm_resource.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index d85f0a37ac35..cee3828df655 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -739,7 +739,7 @@ static int ttm_bo_alloc_resource(struct ttm_buffer_object *bo, may_evict = (force_space && place->mem_type != TTM_PL_SYSTEM); ret = ttm_resource_alloc(bo, place, res, force_space ? &limit_pool : NULL); if (ret) { - if (ret != -ENOSPC && ret != -EAGAIN) { + if (ret != -ENOSPC) { dmem_cgroup_pool_state_put(limit_pool); return ret; } diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c index 9f36631d48b6..b0efffe5a526 100644 --- a/drivers/gpu/drm/ttm/ttm_resource.c +++ b/drivers/gpu/drm/ttm/ttm_resource.c @@ -385,8 +385,11 @@ int ttm_resource_alloc(struct ttm_buffer_object *bo, if (man->cg) { ret = dmem_cgroup_try_charge(man->cg, bo->base.size, &pool, ret_limit_pool); - if (ret) + if (ret) { + if (ret == -EAGAIN) + ret = -ENOSPC; return ret; + } } ret = man->func->alloc(man, bo, place, res_ptr); -- 2.54.0