Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4121695imw; Thu, 7 Jul 2022 13:09:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1shkRDSsxo3UOY5lbxVSMDKC2wg/dJEYk8TbyMuXuQ1LpNvit/KwW0ndrTwstgoZKEB/G4f X-Received: by 2002:a17:902:b60a:b0:16b:d6e9:fce9 with SMTP id b10-20020a170902b60a00b0016bd6e9fce9mr30208693pls.124.1657224552081; Thu, 07 Jul 2022 13:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657224552; cv=none; d=google.com; s=arc-20160816; b=Z8x90J/cK1lx09OJOJsBCqkIPH6EHoBInDti/OTTfCEMdAYkioFFCQ3LLgdEh9QY4Y SiA1JODD4f+moRXU4gAU88YPUha614Aej4QeEXDe4HbwFYnc/U7nvILUPnT1gpp4qTAJ hVjQG1x3KeWbzTf3II0zLIac62bHdseO1e6PbKLChlzBSSSjeEaHBN6Jn9NvcVUtoCvo jEUH+eJ+3P+YSyeeAzx7gr1Mj/ZRlFCbWIdNEC4AijsQHxoUqiAfvJ9ITZWg0xvR3mjf VLczu3EZCA50Kzc1cOOmwmRglQyiCNxXVa8kYKSF9dc7KHJRfasMLjI+ROz4ruNLYM+u AHKA== 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=NMXoyFR/AJn6XTm2nlwKc+bty88WyPnNq34BStdYhaiHUAnLF1IgJcNYcw5JZrjL/m K8IyF00ml8/aCEtpYer3sCcPQSqipcK52hiRhYkOOmFmm9xm+kLPSORE5kDWv3/q15eb FRQJ2olvuPqgTANZc4jAcB3HmWsCgHU7S8DV54M8bE+t5rV6ntabKgDiwyBDu4wtjOJA ijx1I0eMfMfR0s+AUMbiv3k8962QNg44aKjBZ0kOloIz110OwJpyoRQc46TWVwFpAdzt u498991RQb06oGJTa9rpnsSMnJ2vdeyJ0zq/WFcaR75l5AFVfDwc5m7eJtNQDE3to9Hm CIOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DkdaUT9K; 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 b38-20020a631b66000000b0040d6a795447si2385137pgm.510.2022.07.07.13.08.28; Thu, 07 Jul 2022 13:09:12 -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=DkdaUT9K; 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 S236547AbiGGUDE (ORCPT + 99 others); Thu, 7 Jul 2022 16:03:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236495AbiGGUCt (ORCPT ); Thu, 7 Jul 2022 16:02:49 -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 0EEA11FCE4 for ; Thu, 7 Jul 2022 13:02:49 -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 A4C9D66019DD; Thu, 7 Jul 2022 21:02:47 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1657224167; bh=vcV9d53cSiZS9S6xUBuwTwjcLWVgxyTlm1c7ldt4HDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DkdaUT9KatkLleaiwgAQXYI5tiMl4pr7LWT3/t9PDKeOVGNBCamBwHfChCGxn6FpO xP4dFE70BvWSXHUzda+yHPqbXv7s0MyYpPfGQM5sdl2Mh0bjDh43mfjst82FRUDgHL Wo4wESi3d3rPIRtRqT8qD263nLVzjRLyeH00YMZrrkf4LMukqm+4vZdL6xrGFaCc/j Qakp0dMbC37zF/3DArOAaGy0CAcJInWyhdWRCnZJoVh6F+lHRQ3bNcIVwUGpAl2xEH pI3qgQEyQve11NAxOk5QJLgygwc++0l8PXrWsEbb/r2ZMILOArx8k+iz5xe5XElcEZ pMyQXDuLsDWMg== 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 v10 07/11] drm/i915: ttm move/clear logic fix Date: Thu, 7 Jul 2022 20:02:25 +0000 Message-Id: <20220707200230.1657555-8-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707200230.1657555-1-bob.beckett@collabora.com> References: <20220707200230.1657555-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