Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3234121iog; Mon, 20 Jun 2022 14:49:19 -0700 (PDT) X-Google-Smtp-Source: AGRyM1ueIR4WT5PbYNK3d+201SZlIIQHFfU1rHin/jFW0AHrjKSYZw9hrEqV9Oqh6Z1Sgf/hggV7 X-Received: by 2002:aa7:d283:0:b0:435:6dc7:c3e9 with SMTP id w3-20020aa7d283000000b004356dc7c3e9mr17903554edq.197.1655761758906; Mon, 20 Jun 2022 14:49:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655761758; cv=none; d=google.com; s=arc-20160816; b=IX6I3Bldu3AtbSIn04t2MHS1XP/x0DLaY5zdOBM+6mHf8XwetxJOfHy3/S6yLebw+H 7HG71KycHrREqZoaFcjDdBE0BJ9JvDjw8xSkPc4VrGT7EtvPWicaDDaco49UuOsanZbh pbdgyU9HpkSnvQRDVuhWtaXJS0pz4IckDYqFtQ460Ti7PTsSIgpvso9Q+iU7ghAjp3Qf rnjWMh6py43AJJNaRcjX41ikLAgWcpQ2BsbZ5uHVDlVg+imRUkrGGC15Uuu2mzt6Q5ha 9rMk3kUKFWOQUwalA+ZIrGYu+SIVju7p0vZJGDwux8VXi+SrecoVrR8kQfwPmuQjj/yX duHQ== 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=xmcwTPtI1vaf90LcNereWX3EsoXbRpDgjKFixnzC6CAnwtzKOsi4fKHgDuBBg3LYHZ olkxCWLNDCqFGmmxxSVdZ/nsIfmpk96+XA2fL3t3/wyAzl6vtCIvzS7B1RJr4fvvnKXx B2JceFVH4dd8DNzUtVS5ijCNDJZ4dnjjKYKa4ITZ8fOFBNK3HU0eYuMdvrmOo7qeOGB/ wmovtvwRhJrLRT5FMa7Si3I89KXUEvGtlED/KDmgU9v/Td0RQlbXSDi4GwVVC8sM5EMX YuVlwecjfAWzBuQdV8HIP/f8G/4ea9U5phVyJnOkPFR9R2HSR38l9E/Xzh+yyAv+Bf/A gDqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=dV7iU+ee; 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 v10-20020a056402348a00b00435583be8b0si15364765edc.212.2022.06.20.14.48.53; Mon, 20 Jun 2022 14:49:18 -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=dV7iU+ee; 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 S241258AbiFTVem (ORCPT + 99 others); Mon, 20 Jun 2022 17:34:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243518AbiFTVeS (ORCPT ); Mon, 20 Jun 2022 17:34:18 -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 C1E2F15816 for ; Mon, 20 Jun 2022 14:34:16 -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 D3DDB6601863; Mon, 20 Jun 2022 22:34:14 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1655760855; bh=vcV9d53cSiZS9S6xUBuwTwjcLWVgxyTlm1c7ldt4HDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dV7iU+eeCyEGjHaVik+qAf4KmsRPhz/eLYpKoWACkbstkzDRobOwv1zX963CchJ0F 0zXQv5I7yWaPnMSlxGBlbFBLCIIFZ8ZnbtkAWi/3JMIGV6FpSABax1CZGrS0JILHUH +eeUWzaVvtLysN4qV5bkDFf/iViZNIGim5mJeP4BRHFWJFaFQkUNa9oqddIQcVvHrr h0oHuWWVO3ni/qsj4CPJMF314gEwLMwHSCNTx2bALPV9/q1bffWoiNnnGQd/Qlayzp c96WvB4VNbykcVhOSYYZpw8V+/f2Jk/pu6L7fP+GJ8LMSRHUi3GO/M9o8u2v5MBYrL oFJRGKGuuT2mg== 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 v7 07/10] drm/i915: ttm move/clear logic fix Date: Mon, 20 Jun 2022 21:33:37 +0000 Message-Id: <20220620213340.3199605-8-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220620213340.3199605-1-bob.beckett@collabora.com> References: <20220620213340.3199605-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