Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp718468imw; Wed, 13 Jul 2022 06:52:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1umzDMa0WEJd7inklttECMTPgjRIDRtidwrPNhaQ4uLWwqOQbFF4AU5P++0T4ikDsnv5j63 X-Received: by 2002:a05:6a00:1a46:b0:525:82e2:a0d3 with SMTP id h6-20020a056a001a4600b0052582e2a0d3mr3216830pfv.48.1657720322336; Wed, 13 Jul 2022 06:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657720322; cv=none; d=google.com; s=arc-20160816; b=n1D5ab1+HtKQ9Gl6HhgiZd9R3CzhLt34Gyfi2Uc1rJ6x58UVy/Un38wcsH0p0Fj512 egX/VWn/s2L+GP/tdatloo3JgLdPBUGHXhiNHDYceq22vyDd1iCGW5qB+xaGlJLK6ckT feW5l/ubMy97qcLpDMwMOBapJ+3Xbu1H40LOOOSFW+NajDY1UCLcdGnVt+41DLp+jTAG Ze7biObZEp2JVvzfcfjh+4lZolDk0SlrI61ve9ao4Gq8wkda88bQZQR7err+FvMyg5Tw 9gzwCMjA+3yAvn4vuoO4khc8+u/M8pO+X3U9pJAGbqWXq74csL/+x4WlI0Qp/w/2ReCP 6+3w== 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=nktBlx1csroO8xXIyCoXOsNWdJg/GKjzQEr3RQyyFXI=; b=bh5BkFGxCASR6jJDyhGiqEVNiSY4zFthv0JwduGuBV38cfnS8tZKG0fv00wm9Q2myw sMPlv0Jse3S9tNT0IUzDFoPnf7XO4zXG+kvYFNMmiKRnEaKU5U+f4/AAvTX3ayW4emQ5 daUBlPlVXmhjl99JLD6DBqu9q6t+gFEJvhtfrdw2kAhhvEH9QhLZpsI+mRCvmDnm1die UdYBOL/HruDxulWV/OBPCpK/ANztuLvY0Y25Sq0Kdq19xtjUUjNEGzhiEjPufhI9Iybj oMS8xFit3VTfM7IOdExwO77xsHQmItBBNgyTrlAOy/IH5QCM4UXySVArBtLIjCFIoks9 hMAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=DXwj3YfP; 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 ck18-20020a17090afe1200b001ed37b0be62si2205063pjb.90.2022.07.13.06.51.50; Wed, 13 Jul 2022 06:52:02 -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=DXwj3YfP; 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 S236063AbiGMNuo (ORCPT + 99 others); Wed, 13 Jul 2022 09:50:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229918AbiGMNum (ORCPT ); Wed, 13 Jul 2022 09:50:42 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9393101D for ; Wed, 13 Jul 2022 06:50:41 -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 3926A66019BF; Wed, 13 Jul 2022 14:50:40 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1657720240; bh=CsNQhhmN7tfVGf4HN1uv8HbRGJrZrAmt/638xemnBMo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DXwj3YfPj+jwEGaaCJ/oOqrV2ZdTkRKiyqip2q8qzArc3DJDnGCcZIcoBW861sBnP 1AQMJPS9yXEwIgCwpHig2lZRQT56VZ1ZI3UHBpmbmggLg90r3VPmeJcsCqsDf6gdmj i3OK5F5HpwEnSedmeUJe1R7kZyndUL090IffUUU7dMUSCAS/GjitI2UluXRI7n9kGL 5x0OpJOpqbp9zls4jPtbHOLIfHxL7WjZG+lFlX8g3z7QkJQ+lQO2pc79cSoWSGpf5A iT3ZSOLf1ijDpCxfJ6ELok/v69Ucnc5LQL18j5lolVovU2Asmf2gqNAqgdIgjuQcfp Oz6cBjVUdLUCw== 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 v11 01/10] drm/i915/ttm: dont trample cache_level overrides during ttm move Date: Wed, 13 Jul 2022 14:50:13 +0100 Message-Id: <20220713135022.3710682-2-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220713135022.3710682-1-bob.beckett@collabora.com> References: <20220713135022.3710682-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 ccec4055fde3..966ac2d778d5 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 5cf36a130061..14937cf1daaa 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h +++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h @@ -623,6 +623,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 053b0022ddd0..b6c3fc25d9d1 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -1253,6 +1253,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 9a7e50534b84..042c2237e287 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c @@ -129,9 +129,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