Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp604650iol; Thu, 9 Jun 2022 09:56:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSDP+kInVB08uSm7bkW0rKDXDidTIGjzZQmsFBIpUtd5GiHuvp1Hcu1WP4JMN9eMgGmHWv X-Received: by 2002:a05:6402:405:b0:433:426d:7d59 with SMTP id q5-20020a056402040500b00433426d7d59mr3788281edv.122.1654793798784; Thu, 09 Jun 2022 09:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654793798; cv=none; d=google.com; s=arc-20160816; b=mlfICz1IDqKbo4Ru7mtwEhjR1/SNe2RZNgpX/0kKJvW2hJu1JxZoGqTD3l2FcXqePH Fl8f2Gu6JzSfXE4YADzMEtvyv7wnPpRMEq7dolg4cI3Vvao4wT28IMO/OrXaO2QhpCyY LiWQW64GLzoBUo0QJBYvvfahCDJuPoezf8kylH7FoWVxRDjdVXzOD3kLn5SVhms8ZiuR HLtq9eQ5YNk1d7xXqxw7Er6nzgVwkCwVRbphfVmVmMBsoJpKTGOCS8ewVOQXI/mCn7co i0zVety5b3UGqKbcYfh8G9QUC9sws4Syla2YPHgYydekdtxERZW3OWDt5hQOU6fXSnlp 5Xng== 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=LGe5lXmYV3MKC1//5qTz7irjn1NvBQvyoHkEA+8jUdE=; b=RQ1i2+fXqQLPdpZs1jcJX580aGSEhs6DUQR9MUGpXm+lK2jtaF+M3sLpTsGyh83bD8 cYBt5QyA2yRiuA/dA2XyBGEhRpK9dbHmedKUPz2H/r+6TYPfpAGJFSdIU49+FB5KQmBQ 5gFnG7jxAnG5BzEo+xvb/Av9f7Udu/9OrcJJ78cV+O50XnaDnlZflF54MJDTvdutqUuM e2I6mOKcY9i6oPNicjHRBUKARDQwEzuwkjV0GxUwKZaFeOEjq4XW63/Kau9h5cgrKrcO z/LkwmGnhwGbpHkWUrRU1P/0kcHRR5x2XjfYtBbATvWDOc78oay4f+E4+oN3sLmCHPQi THDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=g8qjmFu0; 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 s3-20020a17090699c300b0070b6d46c7eesi22708924ejn.105.2022.06.09.09.56.06; Thu, 09 Jun 2022 09:56:38 -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=g8qjmFu0; 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 S1344357AbiFIQww (ORCPT + 99 others); Thu, 9 Jun 2022 12:52:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234225AbiFIQw3 (ORCPT ); Thu, 9 Jun 2022 12:52:29 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F2D821C3A7 for ; Thu, 9 Jun 2022 09:52:26 -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 B4A0B66017CD; Thu, 9 Jun 2022 17:52:23 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1654793544; bh=KHg3eOnYqUoUcg57EXhLlpoQHXoJLlQC7w8GyVbN4OU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g8qjmFu0HwOgqRNI4BZDKtXlwymktY7jIVzEt94+v1RFRu7d8mndgZm+GMP5v9LSw 7lkkPww0B8R5F8dI9RwLQIyqlSk4qsW8PniUM/sguq9e5g4D7XDv25Rl+Jl0UtzFH3 bt1NfaAAC0mMezpU67FtSkjp7NOlns/m4jQDACzSL990nDaAQQSpr5NXAwf+8GuJzH bzNcOs0VsLOajIukHj9MpPQhNqs6rtmYrPLpia79w6kbLG8yTuqkMgR8OxSSsaROFO AoZok3ZX+R505LiMOir9V9CfKvraxaS9A14izGPc2hdTBNHglKnk1NnWB7m1M11SDI EDO8ZBFiELvfw== 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 v3 1/8] drm/i915/ttm: dont trample cache_level overrides during ttm move Date: Thu, 9 Jun 2022 16:51:53 +0000 Message-Id: <20220609165200.842821-2-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220609165200.842821-1-bob.beckett@collabora.com> References: <20220609165200.842821-1-bob.beckett@collabora.com> MIME-Version: 1.0 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,URIBL_BLOCKED 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 Various places within the driver override the default chosen cache_level. Before ttm, these overrides were permanent until explicitly changed again or for the lifetime of the buffer. TTM movement code came along and decided that it could make that decision at that time, which is usually well after object creation, so overrode the cache_level decision and reverted it back to its default decision. Add logic to indicate whether the caching mode has been set by anything other than the move logic. If so, assume that the code that overrode the defaults knows best and keep it. Signed-off-by: Robert Beckett --- drivers/gpu/drm/i915/gem/i915_gem_object.c | 1 + drivers/gpu/drm/i915/gem/i915_gem_object_types.h | 1 + drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 1 + drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 9 ++++++--- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c b/drivers/gpu/drm/i915/gem/i915_gem_object.c index 06b1b188ce5a..519887769c08 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c @@ -125,6 +125,7 @@ void i915_gem_object_set_cache_coherency(struct drm_i915_gem_object *obj, struct drm_i915_private *i915 = to_i915(obj->base.dev); obj->cache_level = cache_level; + obj->ttm.cache_level_override = true; if (cache_level != I915_CACHE_NONE) obj->cache_coherent = (I915_BO_CACHE_COHERENT_FOR_READ | diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h index 2c88bdb8ff7c..6632ed52e919 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h @@ -605,6 +605,7 @@ struct drm_i915_gem_object { struct i915_gem_object_page_iter get_io_page; struct drm_i915_gem_object *backup; bool created:1; + bool cache_level_override:1; } ttm; /* diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c index 4c25d9b2f138..27d59639177f 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -1241,6 +1241,7 @@ int __i915_gem_ttm_object_init(struct intel_memory_region *mem, i915_gem_object_init_memory_region(obj, mem); i915_ttm_adjust_domains_after_move(obj); i915_ttm_adjust_gem_after_move(obj); + obj->ttm.cache_level_override = false; i915_gem_object_unlock(obj); return 0; 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 a10716f4e717..4c1de0b4a10f 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c @@ -123,9 +123,12 @@ void i915_ttm_adjust_gem_after_move(struct drm_i915_gem_object *obj) obj->mem_flags |= i915_ttm_cpu_maps_iomem(bo->resource) ? I915_BO_FLAG_IOMEM : I915_BO_FLAG_STRUCT_PAGE; - cache_level = i915_ttm_cache_level(to_i915(bo->base.dev), bo->resource, - bo->ttm); - i915_gem_object_set_cache_coherency(obj, cache_level); + if (!obj->ttm.cache_level_override) { + cache_level = i915_ttm_cache_level(to_i915(bo->base.dev), + bo->resource, bo->ttm); + i915_gem_object_set_cache_coherency(obj, cache_level); + obj->ttm.cache_level_override = false; + } } /** -- 2.25.1