Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4153536iog; Tue, 21 Jun 2022 13:12:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u2MHyz/jHAoB2tzanM9wRQptjQEMyo2+hcjqHbr9jZjvePeX2HNK1LDRonj/mWIVgHm7Yc X-Received: by 2002:a17:907:7d8e:b0:711:cf4b:9c5 with SMTP id oz14-20020a1709077d8e00b00711cf4b09c5mr27090210ejc.637.1655842370877; Tue, 21 Jun 2022 13:12:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655842370; cv=none; d=google.com; s=arc-20160816; b=q5uyLZV+cEy4nln8SzZvZ/Iox+BiVzrT9GM7ly7l0bU5L3s3KuCh9yxtBO5EjUXONH h3lq7F230EaK5xrOeciqscTMSnOwslCaz/zeK1IUVDP8Aa6LG6FFSYT2YsvkSUFRCgfP VmjbiOHsUrm5kby3lov5mZCVXu3typUuV4VUnUjLmUdA+40sY1Kr/ZKpwV++Cbvlobq6 HlajGPW+BNY/rrMnGF9vbbvdVP+QvhAj8AMSNoI0Xr/CGbAniUYYAaukH7rxtwj94e8e uSZOeWDKtBcrnJ/SOYGaCKgFzJlRdvirCRpdJkwq4HryrBw2SyRzNTu6HENmkKCypi7A UHYA== 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=HFi0mPxmW7lmh6Y9Mcn1L2Pw5+I1k6z/FwTiPeHHnMohIjA2Sl3rSsoRHMMiQlRTM8 pSTDFTik5J3eKCwkQMT14QKi3vvEGNvcnLqzFcuviOmRP7VOnbOkVCzxlS8dyWMR8vO0 RKjF/nezy1zd8Ogjvzgleb+kZgo0+RPg7kSPZxRLyt4/+Yyrw0YGhO2mDQZvd+OMflb7 tz/x7PcJEV6pefxoZtnk6p8tBBuhJxd8dR4XUI77BtUbRKeCWA0KFMjuHERgpkLMrCi7 /siEYW2Tlnvl1Fs5Mhdt5Y7lZap0gWwuHUjUoGVKiy0TIS0lLvqxewDK0qmuIIJuaN1q D4Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YRmNYsYQ; 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 o20-20020a170906975400b00710c2e87a02si5799621ejy.215.2022.06.21.13.12.25; Tue, 21 Jun 2022 13:12:50 -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=YRmNYsYQ; 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 S1354210AbiFUUBl (ORCPT + 99 others); Tue, 21 Jun 2022 16:01:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353085AbiFUUB0 (ORCPT ); Tue, 21 Jun 2022 16:01:26 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DC4229375 for ; Tue, 21 Jun 2022 13:01:20 -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 AA8D26601870; Tue, 21 Jun 2022 21:01:16 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1655841677; bh=vcV9d53cSiZS9S6xUBuwTwjcLWVgxyTlm1c7ldt4HDk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YRmNYsYQHqVsNDCC4KajI32aP20FwVpGEdBgTcJ6hpDE5SUhgo94+fZVo46XriYCO i/xDfxv4OQzaq5RqUkLVDDKMam1EDYJvoCTdD9W70/vFly0CJQcgypU0ao9y6D3zcL Bqm5dLBwUeXn4DexwNQ96WUCOeI4mouwnBbe2Iqu+cfZ1tiEVq1TtZoUa9fcAakrGh 6MF2sI3AtfJsfUIKAT3ybYYS0TNwXc5P0EnijXxhWDNhTYFj+hqWj4Wj2Ruu47aJkG OA8xNJyv+suxFeXgaIoRs3WeVH8qiAHhVMlbcRFJHZygrk5iD56ToJh7gYidRWkld2 o9/jTF121PU8g== 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 v8 07/10] drm/i915: ttm move/clear logic fix Date: Tue, 21 Jun 2022 20:00:55 +0000 Message-Id: <20220621200058.3536182-8-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220621200058.3536182-1-bob.beckett@collabora.com> References: <20220621200058.3536182-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