Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp751242imw; Wed, 13 Jul 2022 07:22:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t8xmqyMQg39CTj3+hUc/nI9NapcKyZFXH7rqrC4mtAxpNzv5ba1JNvXzfyw3oXd30vj1Md X-Received: by 2002:a17:906:9b14:b0:72b:7c96:58c9 with SMTP id eo20-20020a1709069b1400b0072b7c9658c9mr3857706ejc.648.1657722132518; Wed, 13 Jul 2022 07:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657722132; cv=none; d=google.com; s=arc-20160816; b=WqK2YIVM5nQ1cVJyu1OmAsiEef39N/xXRDruhhixdSeG5EHF5K8OnQihza6KpOVYFN R/xhRBwA3ZZmqVOgwZa495jEVKQ8PYYCX6CRQ+NBviUIpO/7UiJC9y41ZvxLgqCSfi6I YQ43mlrVMQ+22Pvevl6HjE+xbyDCg3yai3auZU9b/EgSH4lrKPLPBa1JzUXvOuVT2OIC KFnoioMPbAQk+3UiFacqLRCUfGhL8m0QZBEeSvU1qb7N/qiKE8k9aUrjfsxekN/8ftaU 647Rh36pmPznqFkOeVuNZ7Ztq6sVfchKZY6ieUn0bfy3/E6fzuu2XzrCTCJlx65gOcD4 5/Fg== 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=S082Z5b18tfhSkgLIL62DapABQ4P7AK/vHlQnqqRwtI=; b=IH2+FbVQ6qtK21PuQ1lNnj6JhHrZ53ZY6/yTe+G949Yd8MIAR5Ci+lzSnGF7egCzXo 13A8UZ51BNhHF9J9hzOTdLpjLsAXEgbPOjJ2ca/u4Vwpw1+YM6mtdTZ2qezDAxf3VXxk JDpUfLInzNgHVtbMgqTi82Ej+lp4xXz1pBp6oUn+NLt27J+vB0iih5i7+v+S/fMd5QjE fU/sJCXuV5crOjdAZIeP3+pu1e+g7eSp8+fukoHofEBEvfypoPszRG3mCW1kCIIVOwOR +bRlvTrM9og0sOjubTk84G+HcU6x0CCBtgBacDi//nGcsejDKUW+ZThqQ2muUKfe24Lb wWTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=NBxa3dKz; 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 ho41-20020a1709070ea900b0072b5f51a9fesi15433903ejc.658.2022.07.13.07.21.48; Wed, 13 Jul 2022 07:22: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=NBxa3dKz; 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 S236169AbiGMNj2 (ORCPT + 99 others); Wed, 13 Jul 2022 09:39:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235573AbiGMNiq (ORCPT ); Wed, 13 Jul 2022 09:38:46 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 392846582 for ; Wed, 13 Jul 2022 06:38: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 132556601A3F; Wed, 13 Jul 2022 14:38:43 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1657719523; bh=MjcvOf0vDzQBv8L9PWE+EuweTtTAL68jhBOjMGIS5/w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NBxa3dKzpn0swOp/aq/dWp6Jm6MmA6wiKmCmGAIwRdhIwGbv3Y6OIi4grMy4i+YEs Ot66paKWdZYRIjPbryo7xwOYBT+OWWRfF5qYmFizAcYkXI4P4jEG8B9tW99FLviNAT CAlDIJ7CfDRaOxfgzkDUSs5K9AHDtJNfVazUCJ+cpsfYSMFG9A7QweMW3EfDqPOxFw zYHgskI1+3KPAdnD7Hv+UpIXz//vdPAOHeg71nL0zfeMnVoFR7OYT2hg2IgWl0GEi1 xC6ea30gY1s8itAmjAr2tZxNWAZxXjgFevBEKRdgUHYrNkO7LWxZHTian+6bl82bwW RbaMqt3LkkAyA== 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 v4 6/8] drm/i915: allow volatile buffers to use ttm pool allocator Date: Wed, 13 Jul 2022 14:38:16 +0100 Message-Id: <20220713133818.3699604-7-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220713133818.3699604-1-bob.beckett@collabora.com> References: <20220713133818.3699604-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 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 Internal/volatile buffers should not be shmem backed. If a volatile buffer is requested, allow ttm to use the pool allocator to provide volatile pages as backing. Fix i915_ttm_shrink to handle !is_shmem volatile buffers by purging. Signed-off-by: Robert Beckett --- drivers/gpu/drm/i915/gem/i915_gem_ttm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c index b6c3fc25d9d1..599ed2713359 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -291,7 +291,8 @@ static struct ttm_tt *i915_ttm_tt_create(struct ttm_buffer_object *bo, page_flags |= TTM_TT_FLAG_ZERO_ALLOC; caching = i915_ttm_select_tt_caching(obj); - if (i915_gem_object_is_shrinkable(obj) && caching == ttm_cached) { + if (i915_gem_object_is_shrinkable(obj) && caching == ttm_cached && + !i915_gem_object_is_volatile(obj)) { page_flags |= TTM_TT_FLAG_EXTERNAL | TTM_TT_FLAG_EXTERNAL_MAPPABLE; i915_tt->is_shmem = true; @@ -513,9 +514,9 @@ static int i915_ttm_shrink(struct drm_i915_gem_object *obj, unsigned int flags) if (!bo->ttm || bo->resource->mem_type != TTM_PL_SYSTEM) return 0; - GEM_BUG_ON(!i915_tt->is_shmem); + GEM_BUG_ON(!i915_tt->is_shmem && obj->mm.madv != I915_MADV_DONTNEED); - if (!i915_tt->filp) + if (i915_tt->is_shmem && !i915_tt->filp) return 0; ret = ttm_bo_wait_ctx(bo, &ctx); -- 2.25.1