Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp25757iof; Wed, 8 Jun 2022 14:20:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhmgB6B5REpBB30J0kpUoHjHLyX7VanVLD85FhoiE5k/EAAFCfY0J75zry6zwnqmFOVq9L X-Received: by 2002:a05:6402:1910:b0:42d:f4f8:c7bd with SMTP id e16-20020a056402191000b0042df4f8c7bdmr41492606edz.382.1654723219445; Wed, 08 Jun 2022 14:20:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654723219; cv=none; d=google.com; s=arc-20160816; b=V2T12WMSCphAqDzfmF0uwIKeLyNl5wuRJ/oMP5Yet1ZVRFXyT8CVa0FWNgFpSYjmQG 4yvx2GFA6o+UK7BOULQQGRTmFm/ik/rT721xtew1mnYiAXy5tJQqflEYN3g20QsdIYbj Rf97fsj9RNFOM4NxnB1Y+BCr3iKNWSp+jMSW/J2verqhGUgpmVJ5GpzIrVJtaTQmr5mA Dmv2nPVAEWEwRil8aKBjx6zFMP7po9mREOsrSORlkurCPtiuzGmOmv246+MB8yw5t5Dr gqyBksOLBnfsv0ph+l2tqKF67F/GjzFZ2bk3CyaZPDnNZISiX27bANsGivmfGcGEXCcp AQ6g== 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=rEZPu1IiAjsKaI8QVfj/pwMy7z8KYxm/wg3bfeBQBE8VDeTinEBzz71d4cRfEgtU27 bFOZrWr3FyznJIKpFnngOT4C/ZBQFK7jFUqxL8PZq4u6SZuto+zxF2q1JLPCaGo50022 aePEytRXgmJelO+PC6O+GZFB0HjWxNFelbYMRYIZ6wRLU3rL3NzRmjPPY0bYXpJJeaYS Sm9DdEkOHvy05FRyl0WwfHkWq+D9XYPCfD0yw+4z/Z/w3k3Giu0L9zB6LSsPsbCt/TtF lo9N7Pe0jz/JGTGtL9WOnCO9rrnSPJI6FEXouL6b4YmltzitTrVXPORHNlnlBNAN768v ud2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=X1jsSDV9; 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 i5-20020a05640242c500b0042dcfe24d06si20948180edc.506.2022.06.08.14.19.53; Wed, 08 Jun 2022 14:20: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=X1jsSDV9; 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 S234752AbiFHUxf (ORCPT + 99 others); Wed, 8 Jun 2022 16:53:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233888AbiFHUw6 (ORCPT ); Wed, 8 Jun 2022 16:52:58 -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 B22A31CB715 for ; Wed, 8 Jun 2022 13:52:57 -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 D0F276601801; Wed, 8 Jun 2022 21:52:54 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1654721575; bh=fNrnNmjm8O3impsJ3FwNrPFJIw42pnJblFgr2kI6zEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X1jsSDV9qIkW0k9U0wTK98H2ECth5LgLSSwPXgE1gQmREyqzW39tKU/XzXHXuT5Hs QXji+EM4q9zv5jgMedjv4I3DR+DcC7pHZGZlve4cVqqEAJL6rvBF3qe1B52PMGpiBz dOxQ4mN7VuvWCcqkhzxpmF34dPpxf/oyLUsVa9DglQXVxmSdphL+uC18TRoCoc68CF 7wI9IV6iwpRNlSAZhG/6Z/nUMSpy27towMbvA5J0T2kPMVvim49B/RBgluej92WKmS MxUgyVAyNle+H56W3h0R0/j3a7nWZ3bscibDXsSl7V7b3Hw0kitVI7/JrcEkraORok pRc3BwpRgyZ8Q== 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 v2 4/8] drm/i915: allow volatile buffers to use ttm pool allocator Date: Wed, 8 Jun 2022 20:51:27 +0000 Message-Id: <20220608205132.438596-5-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220608205132.438596-1-bob.beckett@collabora.com> References: <20220608205132.438596-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 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