Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp937685pxp; Wed, 16 Mar 2022 21:58:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrobECOhvypUh9NIJ895rN4359FdHgFsKUBsmAaGSJrMuu3Pbfilm7VS4/XdFE5mS8a5PD X-Received: by 2002:a17:903:1d1:b0:153:1e35:5a7c with SMTP id e17-20020a17090301d100b001531e355a7cmr3098534plh.0.1647493086226; Wed, 16 Mar 2022 21:58:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647493086; cv=none; d=google.com; s=arc-20160816; b=sUh9WFE1qwqRbP3xCOwolfVz1lg2j2XpMJElAVopWuBMg8BJWAcr30BqntVrUUd63T FjhFXS2qYhbNF34kxMAsRsnJn/e9uXv9uSBIj+FyCLagYcGyqa1QLdF7xNNVk8Wl35CT XKOnd8pJVEmeOTpWm4WoSau+sPXpPZtl0Ls3MNtDA2Cpo94yusU9963WDZaJsDgPjEvR GRxXfw0XfRBaV7g/pzWL+YpwEEW/FkQAWtNy/Flxai4GArZHnn/ec6Man8DSbsNMt8X/ pCspxomUMmYi/4loughKzmcIzqPQ461y8//S7X6XJplbkETyXI9Ru6oTLTqRcnGSgDZu zRMA== 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=qqO+MbuvjuUhCQnbGC3ag5/JUXntNIPAvCSV/5/Zrcw=; b=vFjV6FpqxIu1NO1TNQCHL+HVRKFQnTQ1QtMRgl9YPq5ZDtGx1hpNTqEBJ2Rfdc/L2i WV9DX1SF4FWkjwsiM+02oCJD4mqrnBhmF2IEbHxe/R96HBhBMiZWSx7n6ZZZY6qTeyd7 xDEHWSzR9C0a4DrYVhFrlJCvQJXSN9xq1hsLPQN46ocnVkvomEknYiAZvfMaCT7j/6LT /ydnkWgu6JI1oo26yNdHffqENvHfomiNw55Ueeq+jn/8Yv9UYN+UyacKTKPCHTKmxIJH Uwwjy83f0l0Bdpy6xAMYrfuLRs0k03n1nxO0ljcx4+gYrkwEnBSD2TRXUXMKKlh1WJqJ C8ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TR0nj7nS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id o18-20020a17090aac1200b001c67872070dsi1555526pjq.6.2022.03.16.21.58.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 21:58:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=TR0nj7nS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 17EDD182DBE; Wed, 16 Mar 2022 21:13:47 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350855AbiCOSGW (ORCPT + 99 others); Tue, 15 Mar 2022 14:06:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245048AbiCOSGU (ORCPT ); Tue, 15 Mar 2022 14:06:20 -0400 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD43D205E8 for ; Tue, 15 Mar 2022 11:05:07 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: bbeckett) with ESMTPSA id 4FEB01F43052 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1647367506; bh=li5yvJTQb+uuRirbQROVb1o4GxJGvJ65W8dX02ajYJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TR0nj7nScUIBbszSh1mu7bfxJOH4h5as3e6Qc5h7NMbt+0dnqa+HWqSGd1FCHSRR6 VfsTs3A5ArrTmaw3Lp5EUBnqRh9e/f96py045supEnNw3B3ilZ1yR3MPWxtQws42fc GHizsPbyJArTR13ptzaLN7WR4zPM4FE7wy2gB1HWZvk38xBS+616rnemHdE7H/e34D 3xv0bfQ5Cm74D+m9iu/tDsy4dRGQBpoA19gFNgdxVcgXYv6G6zcwHFzO75NJTC8Ds1 d+PE/Ja/pUnoCXYMFnWW9PPayp9RxXXa3btaQfCDqxptQBVGJ/DtFxT0WvRvggwj+4 Je9ys51gpb1HQ== From: Robert Beckett To: intel-gfx@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter Cc: Robert Beckett , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/7] drm/i915: instantiate ttm ranger manager for stolen memory Date: Tue, 15 Mar 2022 18:04:38 +0000 Message-Id: <20220315180444.3327283-2-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220315180444.3327283-1-bob.beckett@collabora.com> References: <20220315180444.3327283-1-bob.beckett@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=no 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 Signed-off-by: Robert Beckett --- drivers/gpu/drm/i915/intel_region_ttm.c | 29 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_region_ttm.c b/drivers/gpu/drm/i915/intel_region_ttm.c index 737ef3f4ab54..bb564b830c96 100644 --- a/drivers/gpu/drm/i915/intel_region_ttm.c +++ b/drivers/gpu/drm/i915/intel_region_ttm.c @@ -57,11 +57,17 @@ int intel_region_to_ttm_type(const struct intel_memory_region *mem) GEM_BUG_ON(mem->type != INTEL_MEMORY_LOCAL && mem->type != INTEL_MEMORY_MOCK && - mem->type != INTEL_MEMORY_SYSTEM); + mem->type != INTEL_MEMORY_SYSTEM && + mem->type != INTEL_MEMORY_STOLEN_SYSTEM && + mem->type != INTEL_MEMORY_STOLEN_LOCAL); if (mem->type == INTEL_MEMORY_SYSTEM) return TTM_PL_SYSTEM; + if (mem->type == INTEL_MEMORY_STOLEN_SYSTEM || + mem->type == INTEL_MEMORY_STOLEN_LOCAL) + return TTM_PL_VRAM; + type = mem->instance + TTM_PL_PRIV; GEM_BUG_ON(type >= TTM_NUM_MEM_TYPES); @@ -85,10 +91,16 @@ int intel_region_ttm_init(struct intel_memory_region *mem) int mem_type = intel_region_to_ttm_type(mem); int ret; - ret = i915_ttm_buddy_man_init(bdev, mem_type, false, - resource_size(&mem->region), - mem->io_size, - mem->min_page_size, PAGE_SIZE); + if (mem_type == TTM_PL_VRAM) { + ret = ttm_range_man_init(bdev, mem_type, false, + resource_size(&mem->region) >> PAGE_SHIFT); + mem->is_range_manager = true; + } else { + ret = i915_ttm_buddy_man_init(bdev, mem_type, false, + resource_size(&mem->region), + mem->io_size, + mem->min_page_size, PAGE_SIZE); + } if (ret) return ret; @@ -108,6 +120,7 @@ int intel_region_ttm_init(struct intel_memory_region *mem) int intel_region_ttm_fini(struct intel_memory_region *mem) { struct ttm_resource_manager *man = mem->region_private; + int mem_type = intel_region_to_ttm_type(mem); int ret = -EBUSY; int count; @@ -138,8 +151,10 @@ int intel_region_ttm_fini(struct intel_memory_region *mem) if (ret || !man) return ret; - ret = i915_ttm_buddy_man_fini(&mem->i915->bdev, - intel_region_to_ttm_type(mem)); + if (mem_type == TTM_PL_VRAM) + ret = ttm_range_man_fini(&mem->i915->bdev, mem_type); + else + ret = i915_ttm_buddy_man_fini(&mem->i915->bdev, mem_type); GEM_WARN_ON(ret); mem->region_private = NULL; -- 2.25.1