Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp662764iol; Thu, 9 Jun 2022 11:10:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1L4MGVfs3hLP5PetNElKBjm4lwCzBn6q9MAU64WQnI4ijDE2h+FvB9W9fG0CONsbk6dRz X-Received: by 2002:a17:902:7089:b0:168:b18e:9e15 with SMTP id z9-20020a170902708900b00168b18e9e15mr2069770plk.102.1654798219896; Thu, 09 Jun 2022 11:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654798219; cv=none; d=google.com; s=arc-20160816; b=AIqWZgmrcBiRmVDhpzCM4fshlk47XVxoba/q106nzk9OgoX87uJasyUozYtxos5B1T Psx4Htwnp6SCsaYahm5NNOlSv2mANgDWtuA2BntGpO4dib2ygy4/0ofEXzCtkmiA6PLX DyLP/YFnmiLrwMObzl4qwpS++0rVCAoltEnDpE2h3eHEda43yEWWYd2qLUjrs2G3Njxi Br91qWJIO9hDz742FkSgKU/D2a06aW8TvzofS5h5L8opcyqCj6NeIZyzKOKsl7zywxjW JmPnuVGyCiD3ArsvkaGhJOW6OZr/gUL1Jz6C7skEUlSZnpVL1tAOk1fOSy0ApvHLT9ic TnhQ== 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=Mmy1OcCCWLh3e0mBpt2QoVBLHnjzVFvqIKld2C5CthE=; b=T+n96xihWYnUCA4EnfOBJXVeB5rXjG5t1wAiiLTVKQvUERURrtl6Q3pNpPIS5U8BFK dE0RuHcQSsS2dUvAogNyCZsyMY/mvFYgxtscwIz9oZB+fXICnthOFFSoFsoXcZVq9pcg waTiCCTd713kcGcL9Jos8c3XOvZyKOL30DXlKmzDB5L34eIgh5zcWlsbB63ejhgQKE5g ML8t5r+wf6ktBA/r1owPLXDx8EkeWivm5huPnz05fPXmQcNPTtTjdRuwQyeS+nyO6Xkv sdVa5F5abBybcVDTu/klH8lf/l4DRCyxr8mneTWpXjYbM2zAtf3dN53c77HE6wzHn83X d5VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=EpKGah8M; 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 i14-20020a170902cf0e00b001675b7b79d4si24056005plg.41.2022.06.09.11.10.05; Thu, 09 Jun 2022 11:10:19 -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=EpKGah8M; 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 S244633AbiFIQwg (ORCPT + 99 others); Thu, 9 Jun 2022 12:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237472AbiFIQw3 (ORCPT ); Thu, 9 Jun 2022 12:52:29 -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 5F6BD227CFC for ; Thu, 9 Jun 2022 09:52:27 -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 CD5A666017BA; Thu, 9 Jun 2022 17:52:25 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1654793546; bh=fNrnNmjm8O3impsJ3FwNrPFJIw42pnJblFgr2kI6zEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EpKGah8MRwcPqjQ95aCfc7Oks1XrRyNlKgTrhFsuhUw2s3yzaRTIoYsy++VgRqvQ5 Oy/gXuwzxwXXFaonnGDftHH9qzCXCKjtF/MEMtxP/q7xQw0howdNcAsAVCn3P5hKYQ Kbc/xg4zKL+o1MMWxLTFRpwbLg/0h7jua9peemWb5Bt7Po3wzD8Zg/QJk8f53P5sD6 ePj1vstZNyUg69igFYvoFsjGWRxMpGCvpoK1EZZwhk6myvgmc6GD+SBuFVTr4NgYqF ElfEg472OJdCcPK0tbEWwiQtU2I/u411NrTuCAXGhbk0Qckeh6POMRbPN0yY/KPU1M cn3s2ysIC8RwQ== 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 4/8] drm/i915: allow volatile buffers to use ttm pool allocator Date: Thu, 9 Jun 2022 16:51:56 +0000 Message-Id: <20220609165200.842821-5-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 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 27d59639177f..8edce04a0509 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm.c @@ -309,7 +309,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; @@ -531,9 +532,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