Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3965228imw; Thu, 7 Jul 2022 10:19:52 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uyP0RVWWlU4/zS6zMMSHXldGgJCeQg0JsosNmIMKWVspBq+/szTzXmE0nIJQQdyX392NRl X-Received: by 2002:a17:906:7a58:b0:724:c5f7:21e9 with SMTP id i24-20020a1709067a5800b00724c5f721e9mr44857572ejo.90.1657214392309; Thu, 07 Jul 2022 10:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657214392; cv=none; d=google.com; s=arc-20160816; b=HUwv0vYFlgM5BDDwrvXMOph2Ph0n+c0CQkZHzHSVUcpWsOwxkRozSqde+fZLBfKSoz whyvFcpmTYKzV4Um2cJH+Y+SbnIQUOMSkT3asq5S7n6WX0xVfGPTFNaxzDMPXGubazSE geqPJnqDvxTQpyOz3kcT9+D10ZxyxH0dpjCiectJFhEpMD7h9mno+yKLHB/w9aUH7lHE mGLd0JqzernndHt8YC+QdqxAHb7d9f2bc1YgXNoCVTRYhevURJ94WEaAgM4xr9wkrBd2 1KF4BzxXKugD+bhCiDhxa0qNQ10S5UIf4nB4IJOzTjuyAmsQdKiQfxpwkCLmHpPU+3uj Hccg== 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=CT/zG/CLOOPq6AZ7dO0yjULaEz/n0s3wRCL+USKgbidKCBRkusMIIqlBadHMdVXHUR ZqieUoSa9YDDr/oHFw4v0ITY7RKdODZatAjxzbM38uHN7CsDjHcqxVzPM7dBrjcesIKM pKjbnTuryD12Zo52aeEJoFgDyb4yIeghLnUzVHxuDxGgG6rXKV6qkClkHmNBjBw4C5Dl J6tAdPsWwRMFIG3za2icThJmokyKl4ryWBwp5nySo4Xj9wI8N3qQ1lhXyRy02uL7f7tW 2CJXrkh96yU6V5s5HE4VCUa9LcSlC3bGVznHZwTdld9xIrpaO45IegTPMaW0vu3fqepD jqTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=SGPVkSDy; 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 y25-20020a056402171900b0043a93d82354si2061875edu.193.2022.07.07.10.19.26; Thu, 07 Jul 2022 10:19:52 -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=SGPVkSDy; 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 S236313AbiGGQhJ (ORCPT + 99 others); Thu, 7 Jul 2022 12:37:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236205AbiGGQgt (ORCPT ); Thu, 7 Jul 2022 12:36:49 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 004544D159 for ; Thu, 7 Jul 2022 09:36:48 -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 84BEA66019D4; Thu, 7 Jul 2022 17:36:47 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1657211807; bh=vcV9d53cSiZS9S6xUBuwTwjcLWVgxyTlm1c7ldt4HDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SGPVkSDyvujh3ezfQJQv1vBbaQtKiuwr/nNkAlIzfjRgG9y6yws1btEGuGe2x4dyW z/+yVATrQGGrqXzi5CVEQcKn/cLhwLq5Q18lgUGA1eD2LMRQ2gJ8cH/xP1i08qte9i yk7yTdKfOySIa6qFYR4ru/Ij3ANOB8UHUISnd4d1nkZcJAJRJmAsyjhCL+2gtrgG27 vDl4BGZ1/SPeBbU3apVwZrcy+DbFY2DRB047z41i8JwmGqs2iYyRzzkdMaHT8ZudvK FnlGzqisnGW4IjxKcnj7vte5oXu8flD/J1athsyfzqnJummXOjJEc0h0o6bKlII6cA BoSCTFUp+kfjA== 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 v9 07/11] drm/i915: ttm move/clear logic fix Date: Thu, 7 Jul 2022 16:36:02 +0000 Message-Id: <20220707163606.1474111-8-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707163606.1474111-1-bob.beckett@collabora.com> References: <20220707163606.1474111-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