Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp729419iog; Fri, 17 Jun 2022 12:15:49 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s9K5bhbCyndPT6KEPxK53cssMF3pslJUIjGpSv4eGqLTgjtFxd1JL3LNtAvlUil8HUrEf8 X-Received: by 2002:a17:907:6d1a:b0:71b:e858:d187 with SMTP id sa26-20020a1709076d1a00b0071be858d187mr8336783ejc.596.1655493348943; Fri, 17 Jun 2022 12:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655493348; cv=none; d=google.com; s=arc-20160816; b=KwHjl7JrtNyFZzYQ0cFO4AdcCyvi74+TbUecS4zsqpfFiMhFHOSqA+gFPDKkaItvAI eJuDpeH8AJ3U6YmzgiZ+mLASBCwXkttYZu6GW3MEKftFFqyZMtp+E5l0BZLSaKY7R5dh IJy5moCjnrC3y90wGryEQNEOD0nm5jEyhT8ZTcJ1oOpJtv49+44StCWEq8HTky360Q2G 2VAHB4bpG5A1wbvgN72FBPA66/yV/NgDp0L59paajhdhMkZfP8YX2ZIYzACP9sr9+QWb tF3wW/Vt5FSR8QPN86wc1NbF8M+yF1F/bgEact8/bLOUTAE5H+RSur5BKy2pA04V98W3 gyfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=I4yMgRxzpvdGHso+tDSElz8QywwABm5ZA4Q19UFszVM=; b=pN5wD2wUvUk2YtunfaNLCo9CXXuQ6OPmLLZz+hTX+2ucAj33OZNeGHOUmDD+poLW+9 CISv7YnQZx/sOzx7lMwpo+OF8iTaG/R6XkrJAAekFsEe+aUmfhK9FWvUlxnFCSjv6Ob7 ILhgHt/gS7wAGVvU2Stooc+5jwsEzeB6HkdMbgdzDPqkXfO64K5dCiA5/xmjkxIfiK3E SA404dZa2mS0iL38qZVWDMDt/TSe+Af/sRgeArEdgloktIa0DXPJtOs/TpqCei1AMyY8 3oiW4MWc8kqtsC7CGHJLwNw5L09lJJXw8vs2wfG+STIDo1mcX4IgK0tBlBkwILrhmvOZ RSBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=i+hkHucK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y5-20020a056402440500b0042b2375f906si7548477eda.327.2022.06.17.12.15.24; Fri, 17 Jun 2022 12:15:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=i+hkHucK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231193AbiFQTGL (ORCPT + 99 others); Fri, 17 Jun 2022 15:06:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234893AbiFQTFr (ORCPT ); Fri, 17 Jun 2022 15:05:47 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B471046168 for ; Fri, 17 Jun 2022 12:05:46 -0700 (PDT) Received: from hermes-devbox.fritz.box (82-71-8-225.dsl.in-addr.zen.co.uk [82.71.8.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbeckett) by madras.collabora.co.uk (Postfix) with ESMTPSA id 24ECF6601873; Fri, 17 Jun 2022 20:05:45 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1655492745; bh=vcV9d53cSiZS9S6xUBuwTwjcLWVgxyTlm1c7ldt4HDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i+hkHucKjHRuY4mnbF4cULgiFLdGwWTTkdYA19c1mXaMSaVDocMSd0hhkEod7f0g1 cx6UyvPXgtBY016pdNBnizarsszi2Y3Hr9cOSkReL9AMg93T5joh9nA85IZmv7NPha u73H+nMNgFBAxzX08t0/X3twi3Mf2EGnIFdZy6cVQPIwBDyqzKnxZywhn7X1TSXYVV 1LOticG/tJ0Zd0a7H0DLor8qAEKf1QvjauOAIO5MxdWZwlVTSPQknJkSeImUIj9kGr LlfbC7dfOpLnHRjR+jTnRkltsontDBTQvYq1FwYk4d5m4RwAf2+yWLTQbqTtFRkVY3 2BMZ3r6fdTOfQ== From: Robert Beckett To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter Cc: kernel@collabora.com, Robert Beckett , Matthew Auld , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , linux-kernel@vger.kernel.org Subject: [PATCH v6 07/10] drm/i915: ttm move/clear logic fix Date: Fri, 17 Jun 2022 19:05:13 +0000 Message-Id: <20220617190516.2805572-8-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220617190516.2805572-1-bob.beckett@collabora.com> References: <20220617190516.2805572-1-bob.beckett@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ttm managed buffers start off with system resource definitions and ttm_tt tracking structures allocated (though unpopulated). currently this prevents clearing of buffers on first move to desired placements. The desired behaviour is to clear user allocated buffers and any kernel buffers that specifically requests it only. Make the logic match the desired behaviour. Signed-off-by: Robert Beckett Reviewed-by: Thomas Hellström --- drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c index 81c67ca9edda..a3f8fc056dbc 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c @@ -3,6 +3,7 @@ * Copyright © 2021 Intel Corporation */ +#include "drm/ttm/ttm_tt.h" #include #include "i915_deps.h" @@ -476,6 +477,25 @@ __i915_ttm_move(struct ttm_buffer_object *bo, return fence; } +static bool +allow_clear(struct drm_i915_gem_object *obj, struct ttm_tt *ttm, struct ttm_resource *dst_mem) +{ + /* never clear stolen */ + if (dst_mem->mem_type == I915_PL_STOLEN) + return false; + /* + * we want to clear user buffers and any kernel buffers + * that specifically request clearing. + */ + if (obj->flags & I915_BO_ALLOC_USER) + return true; + + if (ttm && ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC) + return true; + + return false; +} + /** * i915_ttm_move - The TTM move callback used by i915. * @bo: The buffer object. @@ -526,7 +546,7 @@ int i915_ttm_move(struct ttm_buffer_object *bo, bool evict, return PTR_ERR(dst_rsgt); clear = !i915_ttm_cpu_maps_iomem(bo->resource) && (!ttm || !ttm_tt_is_populated(ttm)); - if (!(clear && ttm && !(ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC))) { + if (!clear || allow_clear(obj, ttm, dst_mem)) { struct i915_deps deps; i915_deps_init(&deps, GFP_KERNEL | __GFP_NORETRY | __GFP_NOWARN); -- 2.25.1