Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4167249imw; Thu, 7 Jul 2022 14:00:16 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sACjbHxlG0XpfLk8AONAVgQRDOuFtsVYL8sdlD8oe+nqCQ6POqETZnZh0fKXQLtVeMVRZL X-Received: by 2002:a17:902:8ec9:b0:168:c341:847e with SMTP id x9-20020a1709028ec900b00168c341847emr56034571plo.170.1657227616558; Thu, 07 Jul 2022 14:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657227616; cv=none; d=google.com; s=arc-20160816; b=uS8ITy58bx03o2zG4rHtqA8bwv6i1ihpZdTkRrKShd+1oMtYbPkwHuJXJOeQhARwLL VIGaA/zFofbw1rSam8CMaJOtfE3qvv22QSklf9OX/2whdbnnUNZ/5O5tXRV9kIEpQpTf uxRN9KV/GdUEtweoyQBZgeE2Ceftb0ig9plMThcMYtNXCIDMQVJhF+GCNYYvJS7lJ2Lr xNBkqWMDx5MntRLspHPO6C3LScARoqS9Dp4TWVVG7ML8jDqbEU35C+e/SQ/5pH+gXpqq PYSZRTmHxgfJK/3xoRmkUfPs66d+ZR6j010ZB3YIezCl5ZurQf103cfTWW/jJJIjTJgQ Vr1g== 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=1BdMJL3SxvWTodA5n/m38BQSncNUfhzzkzidQydpgjE=; b=mHl6xgWvhf60DOrRS8cpqFpD2tvL9DOCdDndP0bnvfjSpX64V/QTZzd9vnfKIqzsYk Xc09z/Haj1tk3ooihISWOTz4HVB4Jhq95QfXIbcS4PtYuiioBORftQAmk4yRP8GJlY6e 4GIF8Idh5V7g4vcTV/+EKLfmCth/LAeMg+IYG2x9eXr/13HVlAwFAnf9K++aCpn5h4dZ DYfC6giBlvajY7LrsaLUBLPbEOyKcuHL4DZlbul9gqAG0SXgd1iU5DzP5a7pv0OgdOC1 YtQJhF6mYU6C7Og0GhRK59Lmlp1c5LzNBeV8ob8MpgQSzpnapJlL9A4tx6JVHppOL3u0 +aUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=RH+CyuXv; 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 by14-20020a056a00400e00b00527ad0014f6si35893377pfb.339.2022.07.07.14.00.02; Thu, 07 Jul 2022 14:00:16 -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=RH+CyuXv; 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 S236826AbiGGUCw (ORCPT + 99 others); Thu, 7 Jul 2022 16:02:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236739AbiGGUCr (ORCPT ); Thu, 7 Jul 2022 16:02:47 -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 87F141EADF for ; Thu, 7 Jul 2022 13:02:45 -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 DD9BC66019CB; Thu, 7 Jul 2022 21:02:43 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1657224164; bh=2wQM6XEEejfV8LYpxGFHtQpBTSKwot13+IyHpuiYCD4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RH+CyuXvddCAWhla5EfcOd2icXwSgTngfMCwZolc719fEAU7HdLoASvbuETZmOlXR pSgDR/qGVzL6a+x3yb/ZQ0H5oRAKIh6fVlDy62/K6XxMZJMM5VqKs+NOJviXns7ZsA HdywLb/+jpUtRfCqTJiwmg5PvhrCHq1+i4+wLDAqpkkcoi5U+P9xmEZfSQJa6oQqAx 6/3ELJyYXsOc8j7x/iUcw7y15MaLMtfWfDOKWFfT3uxXIt4XTDa7T+NKnKKxiLNv2S 4blRyYGDYgH9iyS1hge50yyxh0DtLaFpmxxZCNU5hN40sd217gXql+jFip0PbQtZsV lU0WFQLlc+kDQ== 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 01/11] drm/i915/ttm: dont trample cache_level overrides during ttm move Date: Thu, 7 Jul 2022 20:02:19 +0000 Message-Id: <20220707200230.1657555-2-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 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 Reviewed-by: Thomas Hellström --- 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